5 Answers, 1 is accepted
Access the corresponding dataItem from client-side and then use the findElement() method to get reference to the Label control in ItemTemplate.
Client Code:
<script type=
"text/javascript"
>
function
getLabel() {
var
grid = $find(
"<%= RadGrid1.ClientID %>"
);
var
masterTableview = grid.get_masterTableView();
var
firstDataItems = masterTableview.get_dataItems()[0];
var
labelControl= dataitems[i].findElement(
"Label1"
);
}
</script>
Go through the following link to know more:
findElement()
-Shinu.
One Q tho re that,...the "i" in
var
labelControl= dataitems[i].findElement(
"Label1"
);
do i suppose that is the 0th based position of the control in the dataitems
i.e lets say i have a checkbox and a label and 2 textboxes (both of which I want to populate from the args retrieved.
Is the "i" then the position of each say 0=label1, 1= label2 2= label3 etc?
(Thereafter I do a postback, such that i can use those vals for calcs in the grid)
but my postback eventargs (in Page_Load) seem not to have ameans of identifying what the event args are. ..kinda restricted to ToString() e.HashCode e.Equals and e.GetType.
So I guess there is a 2nd question .. Where how do I trap in code behind that there is a postback with event args specifically for that forced postbacl
I have a radajaxmanger on the page,...could the ajax partial postback request be of help?
Thx
Neal
I am having no success with retrieving rows (client side) of my radgrid.(which is open and populated and has some 14 rows of data in it (version 2009.2)
I tried the following, using "Alerts" to determine how far it went, and have notated them as successful or not successful.
Any help would be appreciated
thanks
Neal
var masterTableView;
var grid = $find("<%= grvCoverelements.ClientID %>");
if (grid)
{
masterTableView = grid.get_masterTableView();
// alert ("have grid "); //Succesful
}
if (masterTableView)
{
alert(
"have masterTableview " ); ////Succesful
alert(masterTableView.Rows.length);
//NOT successful
for (var i=0; i < masterTableView.Rows.length; i++)
{
alert(
"looping" ); //NOT successful
var cell = masterTableView.GetCellByColumnUniqueName(masterTableView.Rows[i] , "ORateCBX")
and
// var firstDataItems = masterTableView.get_dataItems();
// if (firstDataItems)
// {
// length = firstDataItems.length;
// alert("have length = " + length);
// }
//
// if (masterTableview)
// {
// alert("have masterTableview " );
// if (length > 0)
// {
// for (var i = 0; i < length; i++)
// {
// alert("in for loop" ); //NOT SUCCESSFUL
// var dataItem = dataitems[i].findElement("txtORate");
// if (dataItem)
// {
// // 1. Get the rate textbox
// alert(i);
// var txtRate = dataitems[10].findElement("txtORate");
// alert("rate is " + txtRate)
// }
// }
// }
Note that RadGrid is by design bound control. The ASP.NET platform does not allow editing a database with JavaScript on the client. Therefore the RadGrid could not be updated only on the client without hitting the server as this does not make any sense. Modifying a row only on the client-side without a hit on the server is kind of html injection and it does not correspond with the RadGrid main functionality. The new rows will not be able to handle the main grid functionalities like sorting, paging, filtering etc.
Regards,
Maria Ilieva
the Telerik team
Neal