All
I have been looking at and trying all of the posts showing client-side scripting to get RadGrid selecteditems collection but cannot seem to get there. My code always seems to fail after getting the grid object.
Below is what i have tried. Anyone see where I am going wrong?
//THIS
var grid = window["<%=gvList.ClientID%>"];
// OR THIS
var grid = $find("<%=gvList.ClientID%>");
if (grid)
{
// ALWAYS SUCCEEDS
alert("found grid"); }
// FAILS HERE, error object does not support this method or property
var masterTable = grid.get_masterTableView();
if (masterTable)
{
alert("found masterTable");
var gridSelectedItems = masterTable.get_selectedItems();
}
}
I have been looking at and trying all of the posts showing client-side scripting to get RadGrid selecteditems collection but cannot seem to get there. My code always seems to fail after getting the grid object.
Below is what i have tried. Anyone see where I am going wrong?
//THIS
var grid = window["<%=gvList.ClientID%>"];
// OR THIS
var grid = $find("<%=gvList.ClientID%>");
if (grid)
{
// ALWAYS SUCCEEDS
alert("found grid"); }
// FAILS HERE, error object does not support this method or property
var masterTable = grid.get_masterTableView();
if (masterTable)
{
alert("found masterTable");
var gridSelectedItems = masterTable.get_selectedItems();
}
}
4 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 25 Aug 2008, 10:34 AM
Hi Darryl,
I guess you are using RadGrid for asp.net. If so refer the following link to get details about accessing selected rows on the client side.
Getting cell values for selected rows client side
If you are using RadGrid for asp.net AJAX I would suggest you to send your aspx.
Shinu.
I guess you are using RadGrid for asp.net. If so refer the following link to get details about accessing selected rows on the client side.
Getting cell values for selected rows client side
If you are using RadGrid for asp.net AJAX I would suggest you to send your aspx.
Shinu.
0
Hello Darryl,
To need RadGrid instance for:
RadGrid for ASP.NET (Classic)
RadGrid for ASP.NET AJAX (Prometheus)
The next step is to get MasterTableView object:
or
/this is valid only for RadGrid for ASP.NET AJAX/
Now step on selected items:
/this is valid only for RadGrid for ASP.NET AJAX/
or
/this is valid only for RadGrid for ASP.NET/
or
/this is valid only for RadGrid for ASP.NET/
Kind regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
To need RadGrid instance for:
RadGrid for ASP.NET (Classic)
var grid = window['<%= RadGrid2.ClientID %>']; |
RadGrid for ASP.NET AJAX (Prometheus)
var grid = $find('<%= RadGrid1.ClientID %>'); |
The next step is to get MasterTableView object:
var masterTableView = grid.MasterTableView; |
var masterTableView = grid.get_masterTableView(); |
Now step on selected items:
masterTableView.get_selectedItems(); |
or
masterTableView.GetSelectedRowsIndexes(); |
or
masterTableView.SelectedRows; |
Kind regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Darryl
Top achievements
Rank 1
answered on 25 Aug 2008, 07:26 PM
Thanks Daniel
Sorry I didnt provide enough info, I didnt realize there the two versions have differences in the client api.
So i am using RadGrid and RadToolbar for Asp.Net AJAX 2007Q3. I have a RadToolbar in my RadGrid CommandItemTemplate. The RadGrid either has AjaxEnabled OR is within a panel that is managed with RadAjaxManager. The RadGrid(s) are placed within RadMultiPage Pages, the MultiPage has RenderSelectedPageOnly="true". I intend to use Toolbar.OnClientClick to execute some client-side confirmation of the selected tool.
I am having trouble with async postbacks, keeping the toolbar onclientclick event handler attached, reattaching the handler AND as I stated in the original post, getting number of selected items in the RadGrid. I have tried too many variations of writing javascript (RadAjaxManager.ResponseScripts, Page.ClientScripts.RegisterClientScriptBlock, RadGrid.ClientEvents....) to describe all the details.
Is there by chance some sample or thread that i have missed in my many(obviously poor keyword selection) searches on telerik site that matches this scenario? I am near my wits end. Help :)
Thanks again.
cheers
Sorry I didnt provide enough info, I didnt realize there the two versions have differences in the client api.
So i am using RadGrid and RadToolbar for Asp.Net AJAX 2007Q3. I have a RadToolbar in my RadGrid CommandItemTemplate. The RadGrid either has AjaxEnabled OR is within a panel that is managed with RadAjaxManager. The RadGrid(s) are placed within RadMultiPage Pages, the MultiPage has RenderSelectedPageOnly="true". I intend to use Toolbar.OnClientClick to execute some client-side confirmation of the selected tool.
I am having trouble with async postbacks, keeping the toolbar onclientclick event handler attached, reattaching the handler AND as I stated in the original post, getting number of selected items in the RadGrid. I have tried too many variations of writing javascript (RadAjaxManager.ResponseScripts, Page.ClientScripts.RegisterClientScriptBlock, RadGrid.ClientEvents....) to describe all the details.
Is there by chance some sample or thread that i have missed in my many(obviously poor keyword selection) searches on telerik site that matches this scenario? I am near my wits end. Help :)
Thanks again.
cheers
0
Hello Darryl,
Regarding the RadGrid client-side instance:
the best way to get the instance may be as follows: (valid only for RadControls for ASP.NET AJAX)
This will help you avoid the cases where RadGrid resides in NamingContainers and its ClientID is modified.
You can find an article on attaching/detaching event handlers for RadToolBar:
RadToolBar Client-Side Events
I would like to ask you to elaborate a bit more in order to give you more "to-the-point" answer.
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Regarding the RadGrid client-side instance:
the best way to get the instance may be as follows: (valid only for RadControls for ASP.NET AJAX)
var gridInstance; |
function GridCreated(sender, args) |
{ |
gridInstance = sender; |
} |
This will help you avoid the cases where RadGrid resides in NamingContainers and its ClientID is modified.
You can find an article on attaching/detaching event handlers for RadToolBar:
RadToolBar Client-Side Events
I would like to ask you to elaborate a bit more in order to give you more "to-the-point" answer.
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.