Formated Eval as ClientDataKeyNames

3 posts, 0 answers
  1. Sreenivas
    Sreenivas avatar
    5 posts
    Member since:
    Mar 2013

    Posted 02 Jun 2013 Link to this post

    Hello,

    i am using fulltextsqlquery to get result in share point search and binding results into a grid.

    The query returns "ID" and "StaffID".I would like to format those 2 values as mentioned below in gridtemplatecolumn.

    and i would like to use that formatted values which is say for ex - (1-33333) as my clientdatakeynames.

    Please suggest how could i achieve this?

     <telerik:GridTemplateColumn HeaderText="UniqueID" UniqueName="UniqueID" ItemStyle-CssClass="grid_column"
                                                        Visible="true" ItemStyle-Width="10%" >
                                                        <ItemTemplate>
                                                        <%# String.Format("{0}-{1}", Eval("ID"), Eval("StaffID"))%>    
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>

    Thanks in advance.
  2. Angel Petrov
    Admin
    Angel Petrov avatar
    1007 posts

    Posted 05 Jun 2013 Link to this post

    Hi Sreenivas,

    Since the ClientDataKeyNames should correspond to fields in the data source you can do the following.
    • Set the ID and StaffID as ClientDataKeyNames
    • Extract the wanted value using a JavaScript method which receives a data item as a parameter.

    ASPX:

    <MasterTableView  ClientDataKeyNames="ID, StaffID" ...

    JavaScript:
    function GetClientDataKeyName(dataItem) {
                var clientDataKeyName = String.format("{0}-{1}", dataItem.getDataKeyValue("ID"), dataItem.getDataKeyValue("StaffID"));
                return clientDataKeyName;
            }


    Regards,
    Angel Petrov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.

  3. Sreenivas
    Sreenivas avatar
    5 posts
    Member since:
    Mar 2013

    Posted 06 Jun 2013 Link to this post

    Thanks Angel.I did the same and it worked :)
Back to Top