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

[Solved] Change cell value client side and have it persist in view state.

1 Answer 265 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 02 Jul 2014, 05:05 PM
Hi,

I'm using the following code to change a value in a cell in the grid client side:

function ReAssignUser_UpdateGrid(NewUserText) {
   var grdFlowInstances = $find("<%=grdFlowInstances.ClientID%>");
   var masterTableView = grdFlowInstances.get_masterTableView();
   var dataItems = masterTableView.get_dataItems();
   for (var i = 0; i < dataItems.length; ++i) {
     var dataItem = dataItems[i];
     if (dataItem.getDataKeyValue("FlowInstanceID") == FlowInstanceID) {
       var lblAssignedTo = dataItem.findElement("lblAssignedTo");
       if (lblAssignedTo != null)
         lblAssignedTo.innerHTML = NewUserText;
       }
    }
}


This works great until I do something that causes a postback, then the value reverts to the prior value. I'm assuming this is because it's not getting updated in the viewstate. Is there any way to update the viewstate so that the change in the cell value persists between postbacks?

Thanks,
Erik

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 07 Jul 2014, 08:20 AM
Hi Erik,

I am afraid that you could not change the values in the ViewState. Nevertheless you could change the values on the server on ItemDataBound event handler as described in the following help article. Otherwise if you need to change the values on the client then you need to change them each time when the page postbacks. For this purpose you could use a pageLoad client event handler. Please check out the following code snippet.
<script type="text/javascript">
    function pageLoad() {
        //changing the cells values.
    }
</script>

I hope this information helps.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Erik
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or