GridCheckBoxColumn fails to show

5 posts, 0 answers
  1. Tim Titchmarsh
    Tim Titchmarsh avatar
    9 posts
    Member since:
    Sep 2005

    Posted 25 Aug Link to this post

    Hi

    I am trying to bind some sql data to a grid. Quite simple really. Most datatypes seem to work except GridCheckBoxColumn 

    I have a bit field in sql server (all values populated). I am binding to radgrid with a datasource (LLBLGenProDataSource2) using GridCheckBoxColumn.

    No  data is displayed for the checkbox column . If I bind using GridBoundColumn however it shows up! (True/False) as text

    fails to show

                    <telerik:GridCheckBoxColumn UniqueName="GridCheckBoxColumn" DataField="IsEnabled" HeaderText="Fails" DataType="System.Boolean" >
                    </telerik:GridCheckBoxColumn>

    shows up
                    <telerik:GridBoundColumn DataField="IsEnabled" HeaderText="Works" UniqueName="NewIs" DataType="System.Boolean">                 
                    </telerik:GridBoundColumn>

    If I examine the value in the RadGrid1_ItemDataBound event it is empty (&nbsp;) for the GridCheckBoxColumn but shows True for the GridBoundColumn 

    It seems odd? I can see some of your demos working with a GridCheckBoxColumn , could it be there is a different interpretation of what makes a boolean when reading from the datasource?

    Your help apprciated

     

    I am using the Q2 2016 sp1, VS2015 Windows 7, Chrome

     

    <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
        <telerik:RadGrid ID="RadGrid1" runat="server"
            OnItemCommand="RadGrid1_OnItemCommand"
            OnItemDataBound="RadGrid1_ItemDataBound"
            OnItemCreated="RadGrid1_ItemCreated1"
            PagerStyle-PageButtonCount="5"
            AutoGenerateColumns="false"
            DataKeyNames="OrganisationId"
            AllowPaging="True"
            AllowSorting="True"
            ShowGroupPanel="True"
            RenderMode="Auto"
            EnableLinqExpressions="false"
            AllowFilteringByColumn="True"
            AutoGenerateEditColumn="True"
            AutoGenerateDeleteColumn="True"
            DataSourceID="LLBLGenProDataSource1">
            <GroupingSettings ShowUnGroupButton="true" />

            <ExportSettings ExportOnlyData="true" IgnorePaging="true"></ExportSettings>
            <MasterTableView AllowAutomaticInserts="true"
                AllowAutomaticUpdates="true"
                AllowAutomaticDeletes="true"
                AllowFilteringByColumn="true"
                AutoGenerateColumns="False"
                EditMode="PopUp"
                TableLayout="Fixed"
                CommandItemDisplay="Top"
                InsertItemPageIndexAction="ShowItemOnFirstPage"
                DataSourceID="LLBLGenProDataSource1"
                RetrieveDataTypeFromFirstItem="true"
                DataKeyNames="OrganisationId">
                <EditFormSettings CaptionFormatString="Edit Organisation: {0}" CaptionDataField="DisplayText" PopUpSettings-Width="600px" />

                <CommandItemSettings ShowExportToCsvButton="true" ShowExportToExcelButton="true" ShowExportToPdfButton="true" ShowExportToWordButton="true" />

                <Columns>
                    <telerik:GridBoundColumn DataField="Name" HeaderText="Name" SortExpression="Name"
                        UniqueName="Name" AutoPostBackOnFilter="true" DataType="System.String">
                        <HeaderStyle Width="250px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Email" HeaderText="Email" SortExpression="Email"
                        UniqueName="Email" ReadOnly="true" DataType="System.String">
                        <HeaderStyle Width="250px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridDropDownColumn DataSourceID="LLBLGenProDataSourceType" ListTextField="DisplayText" ListValueField="OrganisationTypeId"
                        UniqueName="OrganisationTypeId" HeaderText="DropDown Column" DataField="OrganisationTypeId"
                        AllowAutomaticLoadOnDemand="true"
                        AllowVirtualScrolling="true" ShowMoreResultsBox="true" ItemsPerRequest="10" DropDownControlType="DropDownList">
                    </telerik:GridDropDownColumn>
                    <telerik:GridCheckBoxColumnUniqueName="GridCheckBoxColumn" DataField="IsEnabled" HeaderText="Fails" DataType="System.Boolean" >
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridBoundColumnDataField="IsEnabled" HeaderText="Works" UniqueName="NewIs" DataType="System.Boolean">                
                    </telerik:GridBoundColumn>

                    <telerik:GridHTMLEditorColumn EditFormColumnIndex="0" UniqueName="Notes" SortExpression="Notes" HeaderText="HTMLEditor Column"
                        DataField="Notes" HeaderStyle-Width="200px" DataType="System.String">
                    </telerik:GridHTMLEditorColumn>
                    <telerik:GridDateTimeColumn UniqueName="DOB" PickerType="DatePicker" HeaderText="DOB"
                        DataField="DOB" DataFormatString="{0:d}"
                        EditDataFormatString="d" DataType="System.DateTime">
                    </telerik:GridDateTimeColumn>
                    <telerik:GridTemplateColumn HeaderText="Attachment" UniqueName="UploadTemplateColumn">
                        <ItemTemplate>
                            <asp:LinkButton ID="DownloadButton" runat="server" CommandName="DownloadFileAttachment"
                                Text="Download">
                            </asp:LinkButton>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadAsyncUpload ID="ImportantDocUpload" EnableInlineProgress="true" runat="server" AllowedFileExtensions=".doc,.docx,.xls,.xlsx,.pdf,.ppt,.pptx" MaxFileSize="4000000">
                            </telerik:RadAsyncUpload>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridTemplateColumn HeaderText="Pic" UniqueName="UploadPic">
                        <ItemTemplate>
                            <asp:Image runat="server" ID="OrgPic" ImageUrl='<%# string.Format(@"{0}.emfile?d={0}",Eval("AvatarImageId")) %>' Height="48" Width="48" />

                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadAsyncUpload ID="PicUpload" EnableInlineProgress="true" runat="server" AllowedFileExtensions=".png,.jpg,.gif" MaxFileSize="4000000">
                            </telerik:RadAsyncUpload>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn DataField="ImportantDocId" Display="false" ReadOnly="true" UniqueName="ImportantDocId" DataType="System.Guid">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="AvartarImageID" Display="false" ReadOnly="true" UniqueName="PicID" DataType="System.Guid">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings AllowColumnsReorder="true" AllowColumnHide="true" AllowDragToGroup="false">
                <Selecting AllowRowSelect="true" />
                <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                <ClientEvents OnPopUpShowing="PopUpShowing" />
            </ClientSettings>
            <PagerStyle PageButtonCount="5" />
            <FilterMenu RenderMode="Auto">
            </FilterMenu>
            <HeaderContextMenu RenderMode="Auto">
            </HeaderContextMenu>
        </telerik:RadGrid>

        <llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSource1" LivePersistence="true" runat="server"
            AdapterTypeName="ExamMeisterDataLayer.DatabaseSpecific.DataAccessAdapter, ExamMeisterDataLayerDBSpecific"
            DataContainerType="EntityCollection"
            EntityFactoryTypeName="ExamMeisterDataLayer.FactoryClasses.OrganisationEntityFactory, ExamMeisterDataLayer"
            OnPerformSelect="LLBLGenProDataSource1_PerformSelect"
            OnPerformGetDbCount="LLBLGenProDataSource1_PerformGetDbCount"
            OnPerformWork="LLBLGenProDataSource1_PerformWork"
            OnEntityInserting="LLBLGenProDataSource1_OnEntityInserting"
            OnEntityUpdating="LLBLGenProDataSource1_OnEntityUpdating"
            CacheLocation="ASPNetCache"
            EnablePaging="false">
        </llblgenpro:LLBLGenProDataSource2>
        <llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSourceType" LivePersistence="true" runat="server"
            AdapterTypeName="ExamMeisterDataLayer.DatabaseSpecific.DataAccessAdapter, ExamMeisterDataLayerDBSpecific"
            DataContainerType="EntityCollection"
            EntityFactoryTypeName="ExamMeisterDataLayer.FactoryClasses.OrganisationTypeEntityFactory, ExamMeisterDataLayer"
            CacheLocation="ASPNetCache"
            EnablePaging="false">
        </llblgenpro:LLBLGenProDataSource2>
        <llblgenpro:LLBLGenProDataSource2 ID="LLBLGenProDataSourceUpload" LivePersistence="true" runat="server"
            AdapterTypeName="ExamMeisterDataLayer.DatabaseSpecific.DataAccessAdapter, ExamMeisterDataLayerDBSpecific"
            DataContainerType="EntityCollection"
            EntityFactoryTypeName="ExamMeisterDataLayer.FactoryClasses.DocViewWithDataEntityFactory, ExamMeisterDataLayer"
            OnEntityInserting="LLBLGenProDataSourceUpload_OnEntityInserting"
            OnEntityUpdating="LLBLGenProDataSourceUpload_OnEntityUpdating"
            CacheLocation="ASPNetCache"
            EnablePaging="false">
        </llblgenpro:LLBLGenProDataSource2>
        <telerik:RadCodeBlock runat="server">
            <script type="text/javascript">
                function onRequestStart(sender, args) {
                    if (args.get_eventTarget().indexOf("Button") >= 0) {
                        args.set_enableAjax(false);
                    }
                }
            </script>
        </telerik:RadCodeBlock>

  2. Kostadin
    Admin
    Kostadin avatar
    1708 posts

    Posted 30 Aug Link to this post

    Hi Tim,

    Could you please verify that the data filed type is boolean and not string. In case yoo are using a string you need to have a values as "Yes" or "No", "1" or "0". You can find more information about this column type in the following help article. If you still experience the same issue I would appreciate if you can provide a small runnable sample in order to investigate it locally.

    Regards,
    Kostadin
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tim Titchmarsh
    Tim Titchmarsh avatar
    9 posts
    Member since:
    Sep 2005

    Posted 30 Aug in reply to Kostadin Link to this post

    Hi

     

    Yes definitely a bool.

    I dug a little deeper and can reproduce with the sample site that Telerik creates when creating a new telerik asp .net web form project in VS 2015 (the c# responsive app based one with grid sample and list view (2016.2.607.45).

    I extended the dataset to include a bool value in the grid.aspx.cs (mybool in the listing below)

            public DataTable GetSellers()
            {
                DataTable data = new DataTable();
                data.Columns.Add("ID", typeof(int));
                data.Columns.Add("Name");
                data.Columns.Add("Age", typeof(int)).DefaultValue = 0;
                data.Columns.Add("BirthDate", typeof(DateTime));
                data.Columns.Add("Rating", typeof(int)).DefaultValue = 0;
                data.Columns.Add("City");
                data.Columns.Add("mybool", typeof(bool)).DefaultValue = true;
                data.PrimaryKey = new DataColumn[] { data.Columns["ID"] };

    ...... etc

     

    and added the field to the grid.aspx

    <telerik:GridCheckBoxColumn DataField="mybool" HeaderText="tim" UniqueName="wdexx" DataType="System.Boolean"/>

    The column is blank in view mode and edit popup mode?

    I tried to attach a file but 23mb zip file. (basically the sample app with the 2 lines added) I can upload it if you wish but where to?

    Thanks

    Tim

     

     

  5. Kostadin
    Admin
    Kostadin avatar
    1708 posts

    Posted 02 Sep Link to this post

    Hi Tim,

    I have prepared a small sample where you can see that the CheckBox column renders a CheckBox controls in the view mode. Could you please check it out and let me know how it differs from your real setup?

    Regards,
    Kostadin
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  6. Tim Titchmarsh
    Tim Titchmarsh avatar
    9 posts
    Member since:
    Sep 2005

    Posted 02 Sep in reply to Kostadin Link to this post

    Hi Kostadin

    Thanks for taking the time to send the sample.

    I ran it as a standalone page, it worked.

    I then integrated into the Telerik Sample app that I was using to build up my app using the master pages - no luck.

    I tracked down the problem, the base style sheet base.css that the master page loads has the entry

    button,
    input {
      -webkit-appearance: none; 
      cursor: pointer; 
    }

    this caused the checkbox (at least on my chrome browser) to disappear. I commented out the -webkit line and it was now visible.

    I guess I should have checked this first...

    Thanks

    Tim

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017