チェンジセット 1651 (default)


以下の違いを無視:
日時:
2024/06/21 20:12:30 (4ヵ月前)
更新者:
hizuya@…
ログメッセージ:
  • SelectField で ItemTemplate を使用出来るようにした。
場所:
framework/trunk
ファイル:
3個の追加
4個の更新
2個のコピー

凡例:

未変更
追加
削除
  • framework/trunk/WebApplication/App_Data/SqlTemplates/UI/WebControls/SelectFieldTemplatePage.st

    r1650 r1651  
    1 # SelectFieldPage.st 
     1# SelectFieldTemplatePage.st 
    22@include resource:FCSoft.SilverFrost.Framework.Web/FCSoft.SilverFrost.Framework.Web.Resources.Data.CommonDbDataSource.st 
    33 
     
    1010                t.collation_name, 
    1111                CASE 
    12                         WHEN t.collation_name IS NOT NULL THEN 
     12                        WHEN t.max_length <= 4 THEN 
    1313                                CAST(1 AS BIT) 
    1414                        ELSE 
    1515                                CAST(0 AS BIT) 
    16                 END [check1], 
     16                END [check], 
    1717                CASE 
    18                         WHEN t.max_length >= 8 THEN 
     18                        WHEN t.max_length BETWEEN 2 AND 8 THEN 
    1919                                CAST(1 AS BIT) 
    2020                        ELSE 
    2121                                CAST(0 AS BIT) 
    22                 END [check2], 
    23                 CASE 
    24                         WHEN t.max_length <= 8 THEN 
    25                                 CAST(1 AS BIT) 
    26                         ELSE 
    27                                 CAST(0 AS BIT) 
    28                 END [check3] 
     22                END [is_small] 
    2923        FROM 
    3024                sys.types t 
  • framework/trunk/WebApplication/UI/WebControls/SelectFieldTemplatePage.aspx

    r1650 r1651  
    11<%@ Page 
    22    Language="C#" 
    3     CodeBehind="SelectFieldPage.aspx.cs" 
    4     Inherits="FCSoft.SilverFrost.Framework.Web.UI.WebControls.SelectFieldPage" 
     3    CodeBehind="SelectFieldTemplatePage.aspx.cs" 
     4    Inherits="FCSoft.SilverFrost.Framework.Web.UI.WebControls.SelectFieldTemplatePage" 
    55%> 
    66 
     
    1616        <div class="test test-webcontrols"> 
    1717 
    18             <h1>UnitTestWeb/UI/WebControls/SelectFieldPage.aspx</h1> 
    19              
     18            <h1>UnitTestWeb/UI/WebControls/SelectFieldTemplatePage.aspx</h1> 
     19 
    2020            <asp:Button ID="PostBackButton" runat="server" 
    2121                Text="PostBack" 
     
    4242                    DataKeyNames="name"> 
    4343                    <Columns> 
    44                         <sff:SelectField /> 
    4544                        <sff:SelectField 
    46                             MultiSelect="false" /> 
    47                         <sff:SelectField 
    48                             DataField="check1" 
    49                             HeaderText="check1 header" 
    50                             FooterText="check1 footer" /> 
    51                         <sff:SelectField 
    52                             DataField="check2" 
    53                             HeaderText="check2 header" 
    54                             HeaderSelect="false" /> 
    55                         <sff:SelectField 
    56                             DataField="check3" 
    57                             FooterSelect="false" /> 
     45                            DataField="check" 
     46                            FooterSelect="false"> 
     47                            <ItemTemplate> 
     48                                <asp:PlaceHolder runat="server" 
     49                                    Visible='<%# Eval("is_small") %>'> 
     50                                    [ <asp:CheckBox runat="server"/> ] 
     51                                </asp:PlaceHolder> 
     52                            </ItemTemplate> 
     53                        </sff:SelectField> 
    5854                        <sff:BoundField 
    5955                            HeaderText="name" 
  • framework/trunk/WebApplication/WebApplication.csproj

    r1642 r1651  
    7979    <Content Include="UI\WebControls\RadioButtonFieldPage.aspx" /> 
    8080    <Content Include="UI\WebControls\RangeValidatorPage.aspx" /> 
     81    <Content Include="UI\WebControls\SelectFieldTemplatePage.aspx" /> 
    8182    <Content Include="UI\WebControls\TemplateFieldPage.aspx" /> 
    8283    <Content Include="UI\WebControls\ObjectDataSourceGridViewPage.aspx" /> 
     
    396397    <Compile Include="UI\WebControls\RangeValidatorPage.aspx.designer.cs"> 
    397398      <DependentUpon>RangeValidatorPage.aspx</DependentUpon> 
     399    </Compile> 
     400    <Compile Include="UI\WebControls\SelectFieldTemplatePage.aspx.cs"> 
     401      <DependentUpon>SelectFieldTemplatePage.aspx</DependentUpon> 
     402      <SubType>ASPXCodeBehind</SubType> 
     403    </Compile> 
     404    <Compile Include="UI\WebControls\SelectFieldTemplatePage.aspx.designer.cs"> 
     405      <DependentUpon>SelectFieldTemplatePage.aspx</DependentUpon> 
    398406    </Compile> 
    399407    <Compile Include="UI\WebControls\TemplateFieldPage.aspx.cs"> 
     
    662670    <None Include="App_Data\SqlTemplates\UI\WebControls\RowStyleFieldPage.st" /> 
    663671    <Content Include="App_Data\SqlTemplates\UI\WebControls\SelectFieldBoundInnerGridViewPage.st" /> 
     672    <Content Include="App_Data\SqlTemplates\UI\WebControls\SelectFieldTemplatePage.st" /> 
    664673    <None Include="App_Data\SqlTemplates\UI\WebControls\SelectFieldPage.st" /> 
    665674    <Content Include="Hosting\ContextDumpHandler.ashx" /> 
  • framework/trunk/WebLibrary/Sources/UI/StyleUtility.cs

    r1642 r1651  
    395395 
    396396        /// <summary> 
     397        /// CSS の <c>class</c> の値をマージして返します。 
     398        /// </summary> 
     399        /// <param name="cssClass1">CSS クラス1。</param> 
     400        /// <param name="cssClass2">CSS クラス2。</param> 
     401        /// <returns> 
     402        /// マージした値。 
     403        /// <paramref name="cssClass1"/> と <paramref name="cssClass2"/> 
     404        /// に指定が無い場合は空文字列。 
     405        /// </returns> 
     406        public static string MergeCssClass(string cssClass1, string cssClass2) 
     407        { 
     408            if (string.IsNullOrWhiteSpace(cssClass1)) 
     409            { 
     410                return !string.IsNullOrWhiteSpace(cssClass2) 
     411                    ? cssClass2.Trim() 
     412                    : string.Empty; 
     413            } 
     414 
     415            if (string.IsNullOrWhiteSpace(cssClass2)) 
     416            { 
     417                return cssClass1.Trim(); 
     418            } 
     419 
     420            return cssClass1.Trim() + ' ' + cssClass2.Trim(); 
     421        } 
     422 
     423        /// <summary> 
    397424        /// 指定されたスタイルをリンクするように登録します。 
    398425        /// </summary> 
  • framework/trunk/WebLibrary/Sources/UI/WebControls/SelectField.cs

    r1341 r1651  
    2525    using System; 
    2626    using System.ComponentModel; 
     27    using System.Diagnostics; 
    2728    using System.Reflection; 
    2829    using System.Text.RegularExpressions; 
     
    9192            = InitializeRadioButtonUniqueGroupNamePropertyAccessor(); 
    9293 
     94 
     95        /// <summary> 
     96        /// <see cref="ItemTemplate"/> の値。 
     97        /// </summary> 
     98        [DebuggerBrowsable(DebuggerBrowsableState.Never)] 
     99        private ITemplate itemTemplate; 
    93100 
    94101        /// <summary> 
     
    245252        } 
    246253 
     254        /// <summary> 
     255        /// データ バインド コントロールの項目を表示するときに使用するテンプレートを取得または設定します。 
     256        /// </summary> 
     257        /// <value> 
     258        /// <see cref="SelectField"/> の項目を表示するときに使用するテンプレートを格納している 
     259        /// <see cref="ITemplate"/> 実装オブジェクト。 
     260        /// 既定値は <see langword="null"/> です。 
     261        /// このプロパティが設定されていないことを示します。 
     262        /// </value> 
     263        /// <remarks> 
     264        /// このテンプレート内にある、一番先頭のチェックボックスに対して選択が動作します。 
     265        /// </remarks> 
     266        [Browsable(false)] 
     267        [DefaultValue(null)] 
     268        [WebDescription("Description_ItemTemplate")] 
     269        [PersistenceMode(PersistenceMode.InnerProperty)] 
     270        [TemplateContainer(typeof(IDataItemContainer), BindingDirection.TwoWay)] 
     271        public virtual ITemplate ItemTemplate 
     272        { 
     273            get 
     274            { 
     275                return itemTemplate; 
     276            } 
     277 
     278            set 
     279            { 
     280                itemTemplate = value; 
     281                OnFieldChanged(); 
     282            } 
     283        } 
     284 
    247285 
    248286        /// <summary> 
     
    297335        internal static ICheckBoxControl GetCheckBoxControl(DataControlFieldCell cell) 
    298336        { 
    299             if (cell.Controls.Count == 0) 
    300             { 
    301                 return null; 
    302             } 
    303  
    304             return cell.Controls[0] as ICheckBoxControl; 
     337            return FindCheckBoxControl(cell.Controls, true); 
    305338        } 
    306339 
     
    382415            Control boundControl; 
    383416 
    384             if (MultiSelect) 
    385             { 
    386                 boundControl = new CheckBox 
     417            ITemplate template = itemTemplate; 
     418            if (template != null) 
     419            { 
     420                // テンプレートを使用 
     421                cell.Text = string.Empty; 
     422                template.InstantiateIn(cell); 
     423 
     424                // テンプレート内の最初のチェックボックスを取得 
     425                boundControl = FindCheckBoxControl(cell.Controls, false) as Control; 
     426                if (boundControl == null) 
    387427                { 
    388                     Text = Text, 
    389                 }; 
    390                 boundControl.PreRender += DataRowCheckBoxOnPreRender; 
     428                    return; 
     429                } 
     430 
     431                // CheckBox の場合に、全てを選択するためのチェックボックスに連動するようにする 
     432                if (MultiSelect) 
     433                { 
     434                    System.Web.UI.WebControls.CheckBox checkBox = boundControl as System.Web.UI.WebControls.CheckBox; 
     435                    if (checkBox != null) 
     436                    { 
     437                        checkBox.PreRender += DataRowCheckBoxOnPreRender; 
     438                    } 
     439                } 
    391440            } 
    392441            else 
    393442            { 
    394                 RadioButton radioButton = new RadioButton 
     443                if (MultiSelect) 
    395444                { 
    396                     Text = Text, 
    397                 }; 
    398                 boundControl = radioButton; 
    399  
    400                 if (RadioButtonIdSeparatorAccessor != null 
    401                     && RadioButtonUniqueGroupNameFieldAccessor != null 
    402                     && RadioButtonUniqueGroupNamePropertyAccessor != null) 
     445                    boundControl = new CheckBox 
     446                    { 
     447                        Text = Text, 
     448                    }; 
     449                    boundControl.PreRender += DataRowCheckBoxOnPreRender; 
     450                } 
     451                else 
    403452                { 
    404                     radioButton.Init += RadioButtonOnInit; 
     453                    RadioButton radioButton = new RadioButton 
     454                    { 
     455                        Text = Text, 
     456                    }; 
     457                    boundControl = radioButton; 
     458 
     459                    if (RadioButtonIdSeparatorAccessor != null 
     460                        && RadioButtonUniqueGroupNameFieldAccessor != null 
     461                        && RadioButtonUniqueGroupNamePropertyAccessor != null) 
     462                    { 
     463                        radioButton.Init += RadioButtonOnInit; 
     464                    } 
    405465                } 
    406             } 
    407  
    408             cell.Controls.Add(boundControl); 
     466 
     467                // ReSharper disable once ExceptionNotDocumented 
     468                cell.Controls.Add(boundControl); 
     469            } 
    409470 
    410471            boundControl.DataBinding += OnDataBindField; 
     
    436497            Control controlContainer = boundControl.NamingContainer; 
    437498 
     499            // ReSharper disable once ExceptionNotDocumented 
    438500            object value = GetValue(controlContainer); 
    439501            if (value == null || value == DBNull.Value) 
     
    600662 
    601663        /// <summary> 
     664        /// コントロールコレクションから最初に見付かった <see cref="ICheckBoxControl"/> を返します。 
     665        /// </summary> 
     666        /// <param name="controls">コントロールコレクション。</param> 
     667        /// <param name="visibleOnly"> 
     668        /// 表示中のコントロールのみを対象にする場合は <see langword="true"/>。 
     669        /// それ以外の場合は <see langword="false"/>。 
     670        /// </param> 
     671        /// <returns> 
     672        /// コントロールコレクションから最初に見付かった <see cref="ICheckBoxControl"/>。 
     673        /// 存在しない場合は <see langword="null"/>。 
     674        /// </returns> 
     675        private static ICheckBoxControl FindCheckBoxControl(ControlCollection controls, bool visibleOnly) 
     676        { 
     677            if (controls == null || controls.Count == 0) 
     678            { 
     679                return null; 
     680            } 
     681 
     682            foreach (Control control in controls) 
     683            { 
     684                // 非表示の場合は無視 
     685                if (visibleOnly && !control.Visible) 
     686                { 
     687                    continue; 
     688                } 
     689 
     690                ICheckBoxControl checkBoxControl 
     691                    = control as ICheckBoxControl 
     692                        ?? FindCheckBoxControl(control.Controls, visibleOnly); 
     693                if (checkBoxControl != null) 
     694                { 
     695                    return checkBoxControl; 
     696                } 
     697            } 
     698 
     699            return null; 
     700        } 
     701 
     702        /// <summary> 
    602703        /// ヘッダーまたはフッターのセルを初期化します。 
    603704        /// </summary> 
     
    645746        private void DataRowCheckBoxOnPreRender(object sender, EventArgs e) 
    646747        { 
    647             CheckBox checkBox = (CheckBox)sender; 
    648             checkBox.InputAttributes["class"] = GetTargetCheckBoxStyleName(); 
     748            System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)sender; 
     749            checkBox.InputAttributes["class"] 
     750                = StyleUtility.MergeCssClass( 
     751                    checkBox.InputAttributes["class"], 
     752                    GetTargetCheckBoxStyleName()); 
    649753        } 
    650754 
  • framework/trunk/WebTest/WebTest.csproj

    r1620 r1651  
    6363    <Compile Include="Sources\ReflectionsTest.cs" /> 
    6464    <Compile Include="Sources\Security\WebSecurityUtilityTest.cs" /> 
     65    <Compile Include="Sources\UI\StyleUtilityTest.cs" /> 
    6566    <Compile Include="Sources\UI\WebControls\ConfirmTest.cs" /> 
    6667    <Compile Include="Sources\UI\WebControls\TextBoxTest.cs" /> 
詳しい使い方は TracChangeset を参照してください。