telerik:GridCheckBoxColumn editable?

6 posts, 0 answers
  1. Henry
    Henry avatar
    42 posts
    Member since:
    Apr 2012

    Posted 22 Jul 2015 Link to this post

    In the radgrid, I have a boolean value binds to telerik:GridCheckBoxColumn.

    By default the checkbox is disabled. Is it possible to enable it in the grid browse mode (not in row edit mode), and allow postback when use check or uncheck the checkbox(so in the codebehind the value can be updated and saved to database)? 

    This is the document for gridcheckboxcolumn: http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/columns/column-types#gridcheckboxcolumn. 

    Thanks.

  2. Jayesh Goyani
    Jayesh Goyani avatar
    2732 posts
    Member since:
    May 2010

    Posted 22 Jul 2015 in reply to Henry Link to this post

    Hello,

    Please try with the below code snippet.

    <telerik:RadGrid ID="RadGrid1" runat="server">
        <MasterTableView DataKeyNames="ID">
            <Columns>
                <telerik:GridTemplateColumn UniqueName="ChkColumn">
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBox1_CheckedChanged" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox CheckBox1 = sender as CheckBox;
        string strID = ((sender as CheckBox).NamingContainer as GridDataItem).GetDataKeyValue("ID").ToString();
        //Perform your DB operation
    }

     

    Please replace "ID" with your primary field name.

    Let me know if any concern.

    Thanks,

    Jayesh Goyani

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Henry
    Henry avatar
    42 posts
    Member since:
    Apr 2012

    Posted 22 Jul 2015 in reply to Jayesh Goyani Link to this post

    This is what I currently doing: have a regular checkbox inside of GridTemplateColumn.

     I was thinking that the telerik:GridCheckBoxColumn ​might be more convenient. 

  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1798 posts

    Posted 27 Jul 2015 Link to this post

    Hi Henry,

    The GridCheckBoxColumn does not support enabled checkbox control in the normal mode, because RadGrid does not support editors in the normal state and only in edit mode. Placing editors in the normal mode is not supported scenario that should be handled manually by the developer and using GridTemplateColumn is the only valid option.

    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Henry
    Henry avatar
    42 posts
    Member since:
    Apr 2012

    Posted 09 Sep 2015 Link to this post

    I had an issue of showing the loading image of another control when user click this checkbox. Below is the code, when the user click the checkbox, the loading image doesn't show on  RadGrid2. Can you help to check if anything wrong?  Thanks.

     

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
         <AjaxSettings>
    <telerik:AjaxSetting AjaxControlID="CheckBox1">
    <UpdatedControls>
    <telerik:AjaxUpdatedControl ControlID="RadGrid2" LoadingPanelID="rdPanel" />
    </UpdatedControls>
    </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>

    <telerik:RadGrid ID="RadGrid1" runat="server">
        <MasterTableView DataKeyNames="ID">
            <Columns>
                <telerik:GridTemplateColumn UniqueName="ChkColumn">
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBox1_CheckedChanged" />
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

    <telerik:RadGrid ID="RadGrid2" runat="server">
    ...
    </telerik:RadGrid>

  7. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1798 posts

    Posted 10 Sep 2015 Link to this post

    Hello Henry,

    With controls nested in GridTemplateColumn you will not be able to include the ID of that controls in the way that you are trying to, because that control will not be in the same scope. For including the CheckBox control in the AJAX settings in this scenario you will have to use the approach demonstrated in the following help article and add the AJAX settings dynamically:
    However, please note that enabling AJAX for nested controls in the grid is not a recommended approach and I highly recommend that you enable the AJAX for the entire grid and add it to the AJAX settings instead of the "CheckBox1" that you currently have.

    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017