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

how to set datakey value (update a radgrid cell client side)

2 Answers 379 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Riaan Booyzen
Top achievements
Rank 1
Riaan Booyzen asked on 24 May 2010, 02:13 PM

Afternoon Telerik Team,

I have a need to update telerik radgrid specific columns in a row client side. 

I set my events in the item created event as shown below (simplified version) and that works as expected.

I then get the client value also correctly, now I need to update this value...there is not SetDataKeyValue of the item available and I cannot find a method on the object (client side) to achieve this.

Should I perhaps use the DataItem client side that I send when attaching the attributes server side to the object to achieve this, if so, then how ?

Can you please assist in the matter ?

Your help is much appreciated.

 function Validate(control, denominator) {  
 
                var firstDataItem = $find("<%=rgCoinBox.ClientID %>").get_masterTableView().get_dataItems()[0];  
 
                alert(firstDataItem.getDataKeyValue("Heading"));  
            } 

 protected void rgCoinBox_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)  
        {  
            if (e.Item is GridEditableItem)  
            {  
                //(e.Item as GridEditableItem).Edit = true;  
 
                switch (e.Item.RowIndex)  
                {  
                    
                    case 3:  
                        e.Item.Attributes.Add("onFocusout", "return Validate('" + e.Item.UniqueID + "','1')");  
                         
                        break;  
                   default:  
                        break;  
                }  
 
            }  
        } 

2 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 25 May 2010, 12:09 PM
Hello Riaan,

The getDataKeyValue method from the client API of RadGrid for ASP.NET AJAX allows you only to extract values from fields that are added to the ClientDataKeyNames array.

If you want to set new values for grid cells client-side, you may consider modifying their innerHTML (see this article for reference). Note, however, that if you want to persist these values, you will need to find a way to send them to the server (using client array or hidden field for example) and update the grid source.

Best regards,
Sebastian
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Riaan Booyzen
Top achievements
Rank 1
answered on 26 May 2010, 09:45 AM

Thank you Sebastian,

I have used a different strategy and I am now using the radgrid's refresh that fires an update to the itemcommand event.

There I the do my calculations and update the needed fields.

Have a good day.

Tags
Grid
Asked by
Riaan Booyzen
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Riaan Booyzen
Top achievements
Rank 1
Share this question
or