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

[Solved] how to update grid values with javascript then persist over postback

1 Answer 186 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 27 Mar 2013, 01:57 PM
My grid has a mastertable and 1 detail table. 
The master table has heirachyLoadMode="ServerBind"
The detailtable columns has ItemTemplates containing a RadNumericTextBox controls (1 per column).
The master table values are essentially an aggregation of the detail rows.  I have RadNumericTextBox ClientEvents-OnValueChanged javascript that aggregates the detail values and updates the the value in the master row.

That all works.  My problem is when a new row is expanded, a postback occurs and I loose the grid values I calculated and set via javascript.  How do I persist those values?  The values in the RadNumericTextBox controls are persisted so EnableViewState can be eliminated.

This is how I update the master rows:
masterView.getCellByColumnUniqueName(masterView.get_dataItems()[masterRowIndex], "MyColName").innerHTML = parseInt(detailTotal / detailRowCount);
How do I persist that change during postback?  Am I not setting the value correctly?  Do I have add postback code to copy HTML values to a saved datasource then rebind?

I cannot use heirachyLoadMode="Client" because loading takes way too long.
I am using ItemTemplates instead of EditTemplates because I don't want the user to have to click edit on each detail row they want to edit; that would slow them down a lot.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 01 Apr 2013, 11:14 AM
Hi Kevin,

Thank you for contacting us.

You can use one of the following approaches to achieve the requested functionality:

1. Preserve the values using HiddenField control and re-assign them on every postback:
http://msdn.microsoft.com/en-us/library/75x4ha6s%28v=vs.100%29.aspx

2. Implement Batch updates:
   Batch Server Update    
   Performing Batch Updates
For putting all items in edit mode:
   http://www.telerik.com/help/aspnet-ajax/grid-put-all-items-in-edit-mode-no-additional-rebind.html
   http://demos.telerik.com/aspnet-ajax/calendar/examples/datepicker/shareddatepicker/defaultcs.aspx?product=grid

Hope this helps. Please let us know if you need further assistance.

Greetings,
Eyup
the Telerik team
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.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or