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

Client-side Selected Records

2 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 02 Nov 2008, 10:37 PM
Can someone tell me why this doesn't work? 

            function GetSelectedIDs() {  
                var cell;  
                var grid = $find("rgEmpTable");  
                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")  
                }  
                var oWnd = radopen("SubmitResume.aspx?PosIDs=" +cell, "SubmitResume");  
                oWnd.center();  
                return false;                  
            } 

What is supposed to happen is that all selected grid items get sent to my radWindow as a querystring.  What happens is that cell is returned as "undefined" and no matter how I tweak it (declare var cell at top) etc it still returns nothing.  Also, this is attached to an asp button using OnClientClick="return GetSelectedIDs();" and I use the return false; to crush the postback.

For the record, the radWindow opens fine but has a querystring PosIDs=undefined.

Sam

2 Answers, 1 is accepted

Sort by
0
Dave
Top achievements
Rank 1
answered on 03 Nov 2008, 01:10 AM
I managed to find what was causing the failure and a work around, but I am not happy with it.  It seems that when you have a column's visibility set to false you can't look it up with getCellByColumnUniqueName.  The answer was to set it visible and make a change to my function which added the selected IDs to an array.  Then join that array with a "," on the open window.  See below for the working function.

            function GetSelectedIDs() {                  
                var grid = $find("rgEmpTable");  
                var MasterTable = grid.get_masterTableView();  
 
                var selectedRows = MasterTable.get_selectedItems();  
                var selIDs = new Array(selectedRows.length);  
                for (var i = 0; i < selectedRows.length; i++) {  
                    var row = selectedRows[i];  
                     selIDs[i] = MasterTable.getCellByColumnUniqueName(row, "empid").innerHTML                   
                }  
                var oWnd = radopen("SubmitResume.aspx?PosIDs=" + selIDs.join(","), "SubmitResume");  
                oWnd.center();  
                return false;                  
            } 

Like I said, I'm not really happy with this because I don't want to display the ID column.  Any ideas how I can pull that value and have the column hidden?

Sam

0
Sebastian
Telerik team
answered on 05 Nov 2008, 12:44 PM
Hello Sam,

You can set the Display property of the column to false instead of Visible = false. Thus the column will be rendered in the browser as hidden and you will still be able to extract the data from its cell on the client.

Further information about the Visible/ReadOnly/Display properties of grid columns you can find here:

http://www.telerik.com/help/aspnet-ajax/grdusingcolumns.html (paragraph 'Visibility and rendering of columns')

Alternatively, use client key values as demonstrated in the following online demo of the product:

http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/Client/Keys/DefaultCS.aspx

Kind regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Dave
Top achievements
Rank 1
Answers by
Dave
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or