Telerik Radgrid to get the selected value using javascript [Resolved]

Posted by Kavi.Sirius under JavaScript on 2/25/2013 | Points: 10 | Views : 20074 | Status : [Member] | Replies : 2
hi,

i need to get the RadGrid id on client side,but i cant able to get the selected row value

i am using this code for get the id
but its not working,returns the null value

function GetSelectedNames() {
alert('hello');
var grid = $('#<%# RadGrid1.ClientID %>');
alert(grid);
var MasterTable = grid.get_masterTableView();
var selectedRows = MasterTable.get_selectedItems();
for (var i = 0; i < selectedRows.length; i++) {
var row = selectedRows[i];
var cell = MasterTable.getCellByColumnUniqueName(row, "EmpId")
alert(cell.innerHTML);
//here cell.innerHTML holds the value of the cell
}


needs some one help

Thanks in advance

Regards
Kavi.n



Responses

Posted by: Kavi.Sirius on: 2/27/2013 [Member] Starter | Points: 25

Up
0
Down

Resolved
hi anish,

i got the solution through the below code

function GetFirstDataItemKeyValues(id) {

var row = id.parentNode.parentNode;
var rowIndex = row.rowIndex - 1;

var firstDataItem = $find("<%= RadGrid1.MasterTableView.ClientID %>").get_dataItems()[rowIndex];
alert(firstDataItem);
var EmpId = firstDataItem.getDataKeyValue("EmpId");

var Empname = firstDataItem.getDataKeyValue("Empname");

window.location.href = 'SecondForm.aspx?Id=' + EmpId + '&Name=' + Empname ;

}



Regards
Kavi.n

Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Anishsethu on: 2/27/2013 [Member] Starter | Points: 25

Up
0
Down
Hi
try this
function OnRowSelecting(sender, args)
{
var key=args.getDataKeyValue("ID");
alert(key);
}
<MasterTableView AutoGenerateColumns="False" DataKeyNames="ID" ClientDataKeyNames="ID" >
pls check whether u have added ClientDataKeyNames in mastertable as mentioned above

call the function in client events as shown below
<ClientSettings>
<client Events OnRowClick="OnRowSelecting"/>
</ClientSettings>

Regards
Anish Sethu


Kavi.Sirius, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response