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

Changing Key Values on the server?

5 Answers 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manny Siddiqui
Top achievements
Rank 1
Manny Siddiqui asked on 03 Feb 2010, 06:15 PM
Guys,

I have a grid that has the DataKeyNames and ClientDataKeyNames properties set to couple of columns. One of the columns is the timestamp column (of type timestamp in the database and byte array in the DataSet that comes from the DAL) and the grid does not store that column's value in the Key Values; instead it stores the name of the type "System.Byte[]".

The problem is that I need the column's value instead of the type name on the client side.

I was hoping to capture some event on the server side to convert the timestamp column's value from byte array to a Base64 encoded string and put it back in the KeyValues so that I could retrieve the value on the client side, but so far I could not find a way to change the key values.

Any thoughts about how should I approach this problem? If changing the grid key values is not supported, then is there any other hidden place (except the hidden column) where I could store the base64 encoded string?

Thanks,
Manny

5 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 04 Feb 2010, 01:46 PM
If you're looking to do this client-side I think the Extracting key values client-side documentation article can help quite a bit :)
0
Manny Siddiqui
Top achievements
Rank 1
answered on 04 Feb 2010, 02:48 PM
Schlurk,

Thanks for taking the time to reply. I am afraid we are not on the same page.

The problem is not with retrieving key values on the client side; rather the problem is that the RadGrid does not store the value of timestamp column in key values! (because the timestamp columns is returned as a byte array from the database). Retrieving the value of the timestamp column in the javascript returns "System.Byte[]" (that tells me that the RadGrid is not storing the column's value in the key values)

I need to convert the timestamp byte array to a Base64 encoded string and put that string in the key values on the server side; the grid should not have problems storing string in the key values. I could then retrieve the string on the client side and convert it back to byte array as needed.

Did I explain it correctly?
0
Iana Tsolova
Telerik team
answered on 09 Feb 2010, 02:02 PM
Hello Manny,

In order to achieve your goal, you can try adding additional column to the grid Columns collection and set its Display property to false. There you can store the desired data and access it on the client using the getCellByColumnUniqueName as described here.

Check it out and let me know if this works for you.

Kind regards,
Iana
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Manny Siddiqui
Top achievements
Rank 1
answered on 09 Feb 2010, 03:29 PM
Iana

Thanks for suggesting the solution.

I really wanted to avoid the hidden column approach but had to use it because I could not find any other way out. Since you are also suggesting the same solution, does that mean there is no way to change Key Values on the server side? Just curious; what is the reason for prohibiting the developers from changing key values?

Manny
0
Iana Tsolova
Telerik team
answered on 10 Feb 2010, 02:43 PM
Hi Manny,

The DataKeyValues collection is built based on the data coming from database. Usually DataKeyNames are primary key fields used for automatic operations, etc. Thus changing the DataKeyValues might be harmful instead of useful.

Kind regards,
Iana
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Grid
Asked by
Manny Siddiqui
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Manny Siddiqui
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or