This is a migrated thread and some comments may be shown as answers.

GridClientSelectColumn onclick

14 Answers 1236 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 22 Oct 2011, 05:51 PM
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.


14 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 23 Oct 2011, 03:06 PM
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.

0
Princy
Top achievements
Rank 2
answered on 24 Oct 2011, 05:38 AM
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.
0
Michael
Top achievements
Rank 1
answered on 24 Oct 2011, 01:43 PM
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.
0
Princy
Top achievements
Rank 2
answered on 25 Oct 2011, 08:42 AM
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.
0
Tassilo
Top achievements
Rank 1
answered on 22 May 2017, 04:52 AM

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.

0
Eyup
Telerik team
answered on 24 May 2017, 10:55 AM
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.
0
Bilal
Top achievements
Rank 1
answered on 15 Feb 2018, 08:01 PM

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,

 

 

 

 

0
Bilal
Top achievements
Rank 1
answered on 15 Feb 2018, 08:31 PM
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);
    }
}
0
Antony
Top achievements
Rank 1
answered on 15 May 2019, 05:12 AM

Hi Princy,

 

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

0
Eyup
Telerik team
answered on 17 May 2019, 06:43 AM
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.
0
Antony
Top achievements
Rank 1
answered on 17 May 2019, 07:32 AM
Thank you so much Eyup!!!
0
Antony
Top achievements
Rank 1
answered on 17 May 2019, 07:34 AM
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. 
0
Antony
Top achievements
Rank 1
answered on 17 May 2019, 07:35 AM
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?
0
Eyup
Telerik team
answered on 17 May 2019, 03:11 PM
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.
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Tassilo
Top achievements
Rank 1
Eyup
Telerik team
Bilal
Top achievements
Rank 1
Antony
Top achievements
Rank 1
Share this question
or