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

Grid: "invisible columns"

6 Answers 100 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gint
Top achievements
Rank 1
Gint asked on 19 Sep 2011, 12:08 PM
Hi there,

I would like to store a key/ID per row which can be retrieved on client-side but is NOT shown to the user.

--

<telerik:GridBoundColumn DataField="Id" HeaderText="Id" Visible="false" >
</telerik:GridBoundColumn>

does not work as '.getCellByColumnUniqueName(row, "Id").innerHTML' is NULL then!

What other options do I have?

Thanks for all suggestions/help!

6 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 19 Sep 2011, 12:13 PM
Hello,

its better to set this property in as DataKey in RadGrid and you can easily get this value in client side also.

<MasterTableView DataKeyNames="ID" ClientDataKeyNames="ID"

let me know if any concern.

Thanks,
Jayesh Goyani
0
Gint
Top achievements
Rank 1
answered on 19 Sep 2011, 12:25 PM
Thank you very much,

I am binding the data with a web service. How can I set/get the IDs per row?
Can you provide some "client-side code"-snippets and/or links?

If I add your code, remove the Column-Definition and try to get the ID using '.getCellByColumnUniqueName(row, "ID").innerHTML' ... I still get NULL.

Thanks for your patience,
Gint
0
Jayesh Goyani
Top achievements
Rank 2
answered on 19 Sep 2011, 12:44 PM
Hello,

Please elaborate your case in detail. (Where and when you want to this ID)


Thanks,
Jayesh Goyani
0
Gint
Top achievements
Rank 1
answered on 20 Sep 2011, 07:43 AM
<MasterTableView DataKeyNames="ID" ClientDataKeyNames="ID"><Columns><telerik:GridBoundColumn DataField="Text" HeaderText="Text"></telerik:GridBoundColumn></Columns></MasterTableView>

is my definition

function updateErgebnisse(result) {
   var tableView = $find("<%= Ergebnisse.ClientID %>").get_masterTableView();
   tableView.set_dataSource(result);
   tableView.dataBind();
}

is my javascript update function

PageMethods.GetErgebnisse(foundItemValue, updateErgebnisse);

is the invocation of my web service

and finally ...

            var MasterTable = sender.get_masterTableView();
var row = MasterTable.get_dataItems()[args.get_itemIndexHierarchical()];
try {
var foundItemValue = MasterTable.getCellByColumnUniqueName(row, "ID").innerHTML;
alert(foundItemValue);
} catch (e) { }

this is how I tried to retrieve the value ... and failed! ;-)

I am not sure whether the column named "ID" is set and even if it is how to retrieve it's value.

Thanks again 4 helping me out here,
Gint
0
Gint
Top achievements
Rank 1
answered on 20 Sep 2011, 07:52 AM
got it! ;-)

<code>var id = args.getDataKeyValue("ID");</code>

Thanks 4 even reading this,
Gint
0
Shinu
Top achievements
Rank 2
answered on 20 Sep 2011, 07:56 AM
Hello Gint,

Try the following Javascript.
JS:
function OnRowClick(sender, args)
{
       var MasterTable = sender.get_masterTableView();
       var row = MasterTable.get_dataItems()[args.get_itemIndexHierarchical()];
       alert(row.getDataKeyValue("ClientDataKeyName"));
}

Thanks,
Shinu.
Tags
Grid
Asked by
Gint
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Gint
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or