GridClientSelectColumn onclick

15 posts, 0 answers
  1. Michael
    Michael avatar
    66 posts
    Member since:
    Dec 2009

    Posted 22 Oct 2011 Link to this post

    Hello, I am using GridClientSelectColumn, and I'm trying to add a javascript onclick event.  I added the following to my ItemDataBound grid event:

     

     

    if (e.Item is GridDataItem)

     

    {

     

     

    GridDataItem item = (GridDataItem)e.Item;

     

     

     

    CheckBox chkbx = (CheckBox)item["ClientSelectColumn"].Controls[0];

     

    chkbx.AutoPostBack =

     

    true;

     

    chkbx.Attributes.Add(

     

    "OnClick", "return alert('" + chkbx.Checked + "');");

     

    }



    But every time, the value is displayed as false after I check the box.  I just want to get the value of the checkbox after it is selected.


  2. Michael
    Michael avatar
    66 posts
    Member since:
    Dec 2009

    Posted 23 Oct 2011 Link to this post

    Also, I have  AllowMultiRowSelection="False", but if there is only 1 row, and the user clicks the row and then changes their mind, and trys to uncheck the row, the row stays checked.

    If there is a scenario where the grid only has one row, the user should be able to uncheck the checkbox after checking it.

  3. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 24 Oct 2011 Link to this post

    Hello Michael,

    You can use 'OnRowSelected' and 'OnRowDeselected' ClientEvent of RadGrid' which will fire when you select/deselect the rows in Radgrid. Sample code is given below.
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" DataSourceID="SqlDataSource1"
           AllowMultiRowSelection="false" >
             <MasterTableView CommandItemDisplay="Top" DataKeyNames="EmployeeID" EditMode="InPlace">
                 <Columns>
                      <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn">
                     </telerik:GridClientSelectColumn>
                 </Columns>
             </MasterTableView>
             <ClientSettings Selecting-AllowRowSelect="true">
                 <ClientEvents OnRowSelected="RowSelected" OnRowDeselected="RowDeselected" />
             </ClientSettings>
         </telerik:RadGrid>

    Java Script:
    <script type="text/javascript">
        function RowSelected(sender, args) {
            alert("true");
        }
        function RowDeselected(sender, args) {
            alert("false");
        }
    </script>

    Thanks,
    Princy.
  4. Michael
    Michael avatar
    66 posts
    Member since:
    Dec 2009

    Posted 24 Oct 2011 Link to this post

    Hi, thanks.  How do I get the value of the GridClientSelectColumn to determine if its true or false?  Also, why if there is only 1 row in the grid, I can't uncheck that row after checking it?

    Thanks for your help.
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Oct 2011 Link to this post

    Hello Michael,

    You can try the following code snippet to access ClientSelectColumn.
    C#:
    protected void grid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
     if (e.Item is GridDataItem)
      {
         GridDataItem dataitem = (GridDataItem)e.Item;         
         CheckBox checkBox = (CheckBox)dataitem["ClientSelectColumn"].Controls[0];
     if (checkBox.Checked )//checking for condition
         {              
         }
      }
    }

    Thanks,
    Princy.
  6. Tassilo
    Tassilo avatar
    3 posts
    Member since:
    Nov 2014

    Posted 21 May 2017 in reply to Princy Link to this post

    Hi,

    I tried to access the clientselectcolumn checkbox from the item_databound event and that seems to be working fine. But how to capture the status change for the check box as it happens through the client side and cannot be captured through the databound event.

  7. Eyup
    Admin
    Eyup avatar
    3962 posts

    Posted 24 May 2017 Link to this post

    Hello Tassilo,

    For client-side you can use the following event handler:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/events/onrowselected

    And for server - the approach demonstrated in this article:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/making-postback-or-ajax-request-on-client-row-click

    I hope this will prove helpful.

    Regards,
    Eyup
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  8. Bilal
    Bilal avatar
    2 posts
    Member since:
    Jan 2016

    Posted 15 Feb 2018 in reply to Eyup Link to this post

    Hi, actually the issue is that we add the GridClientSelectColumn but on that command we want to post back to run a serverside code to enable a few other buttons and things on the page. Is this possible to use the GridClientSelectColumn to post back or trigger some kind of grid event when you select the top checkbox in the header?

     

    of course we can just use client side to manually submit the page but I was trying to stick to asp.net events if possible.

    so please yes or no can we do a server side post back on the selection of the actual GridClientSelectColumn the top check box in the HEADER.

     

    Thank you,

     

     

     

     

  9. Bilal
    Bilal avatar
    2 posts
    Member since:
    Jan 2016

    Posted 15 Feb 2018 in reply to Bilal Link to this post

    Here is the answer to this

    https://www.telerik.com/forums/select-all-rows-event

    The magic is this part:

    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridHeaderItem)
        {
            GridHeaderItem headerItem = (GridHeaderItem)e.Item;
            CheckBox headerChkBox = (CheckBox)headerItem["GridClientSelectColumn"].Controls[0];
            headerChkBox.AutoPostBack = true;
            headerChkBox.CheckedChanged += new EventHandler(headerChkBox_CheckedChanged);
        }
    }
  10. Antony
    Antony avatar
    5 posts
    Member since:
    Apr 2019

    Posted 15 May 2019 in reply to Princy Link to this post

    Hi Princy,

     

    How Can get all Selected values id of Using GridClientSelectColumn on ClientSide?.Kindly Explain me.

  11. Eyup
    Admin
    Eyup avatar
    3962 posts

    Posted 17 May 2019 Link to this post

    Hi Antony,

    You can use the following event handler for individual rows:
    https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/events/onrowselected

    In order to get all of them on an external action like button click, you can use the get_selectedItems() method:
    https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/client-side-programming/gridtableview-object/properties/get_selecteditems()

    I also suggest that you examine the sample provided at the last post here:
    https://www.telerik.com/support/code-library/get-selected-items-through-all-pages#1eTU8nr-GUG8zfGgOGbIcA

    Regards,
    Eyup
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  12. Antony
    Antony avatar
    5 posts
    Member since:
    Apr 2019

    Posted 17 May 2019 in reply to Eyup Link to this post

    Thank you so much Eyup!!!
  13. Antony
    Antony avatar
    5 posts
    Member since:
    Apr 2019

    Posted 17 May 2019 in reply to Antony Link to this post

    Hi Team, I want Upgrade my Sitefinity CMS 7.3 from above Latest version of Supporting ASP.NET  Web forms,Kindly share the Up gradation Process for the Same. 
  14. Antony
    Antony avatar
    5 posts
    Member since:
    Apr 2019

    Posted 17 May 2019 in reply to Eyup Link to this post

    Hi Eyup, I want Upgrade my Sitefinity CMS 7.3 from above Latest version of Supporting ASP.NET  Web forms,Kindly share the Up gradation Process for the Same, Can you help me?
  15. Eyup
    Admin
    Eyup avatar
    3962 posts

    Posted 17 May 2019 Link to this post

    Hello Antony,

    Here you can find proper steps of updating Sitefinity CMS:
    https://www.progress.com/documentation/sitefinity-cms/upgrade

    If you have further questions, you can open a new thread addressing your queries and select the Sitefinity product.

    Regards,
    Eyup
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top