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

retrieving selected grid rows - alternative to getCellByColumnUniqueName ?

3 Answers 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 14 Oct 2008, 03:44 AM
Hello,

I followed the example in this URL to obtain the values of selected rows in the client clientside:

http://www.telerik.com/help/aspnet-ajax/grdgettingcellvaluesforselectedrowsclientside.html

This is my code:

        var masterTableView = $find("RadGrid1").get_masterTableView(); 
        var selectedRows = masterTableView.get_selectedItems(); 
        var count = selectedRows.length; 
        for (var i = 0; i < count; i++) { 
            var row = selectedRows[i]; 
            var cell = masterTableView.getCellByColumnUniqueName(row, "Name"); 


getCellByColumnUniqueName gets me the values from cell.innerHTML, however the values contain the <span ..> element markup enclosing the value, which I don't want. Is there another way to get the values without having to parse out the <span> markup?  I tried the following but it doesn't work:

            // this doesn't work
            // var dataItem = selectedDataItems[i];
            // alert(dataItem.getDataKeyValue('Name'));

Thank you,
Alex



3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 14 Oct 2008, 06:08 AM
Hi Alex,

You need to set "Name" in ClientDataKeyNames in order to use getDataKeyValue() client-side method.

All the best,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Lenny_shp
Top achievements
Rank 2
answered on 05 Dec 2008, 06:14 PM
  var cell = MasterTable.getCellByColumnUniqueName(row, "myColName");

The above works when it's a regular BoundColumn.   How do I get the values of child control within a GridTemplateColumn?

Something like this:  (which doesn't work)
  var cell = MasterTable.getCellByColumnUniqueName(row, "myColName").findcontrol("myCntrlWithin_MyColName");
0
Shinu
Top achievements
Rank 2
answered on 08 Dec 2008, 04:38 AM
Hi  Lenny_shp,

Go through the following code library submission which explains how to access server controls in a Grid template on the client side.
Accessing server controls in a grid template on the client

Shinu.

Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Lenny_shp
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Share this question
or