Changing Key Values on the server?

6 posts, 0 answers
  1. Manny Siddiqui
    Manny Siddiqui avatar
    13 posts
    Member since:
    Jan 2010

    Posted 03 Feb 2010 Link to this post

    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
  2. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 04 Feb 2010 Link to this post

    If you're looking to do this client-side I think the Extracting key values client-side documentation article can help quite a bit :)
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Manny Siddiqui
    Manny Siddiqui avatar
    13 posts
    Member since:
    Jan 2010

    Posted 04 Feb 2010 Link to this post

    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?
  5. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 09 Feb 2010 Link to this post

    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.
  6. Manny Siddiqui
    Manny Siddiqui avatar
    13 posts
    Member since:
    Jan 2010

    Posted 09 Feb 2010 Link to this post

    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
  7. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 10 Feb 2010 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017