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

Grid JavaScript Data Source value update Problem

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raina
Top achievements
Rank 1
Raina asked on 29 Dec 2012, 11:56 AM
Team,
 We are evaluating your product for one of our client project. We are stuck in one problem and wondering like how to resolve.

Please see the steps below:

1. I am using grid and I am doing grid edit event .
  
Please see the code for grid event below:

.Events(e => e.Edit(@<text>
    function(e) {
      var row = e.container;
 row.find("#txtboxvalue1").bind("blur", function(e) 
    {                               
        var test=  $("#txtboxvalue1").val();
           var finalresult=  $("#txtboxvalue2").val(test*0.643);
 });
      row.find("#txtboxvalue2").bind("blur", function(e) 
    {                               
 var test=  $("#txtboxvalue2").val();
 var finalresult=  $("#txtboxvalue1").val(test*1.555);
 });
            }
 </text>))

2. The value what I am giving in event function its coming perfectly fine but I am facing the problem while updating with database because the value is only coming for UI .

3.I want the value to update from data source also.

Please suggest me how I can achieve this .

Thanks ,
Raina

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 31 Dec 2012, 10:15 AM
Hi,

 You need to use the set method of the model in order to properly update its fields in the data source. Try the following:

.Events(e => e.Edit(@<text>
    function(e) {
      var row = e.container;
      var model = e.model; // get the model which is being edited
  
       row.find("#txtboxvalue1").bind("blur", function(e)  {                             
          var test=  $("#txtboxvalue1").val();
          // set the required field to the new value.
          model.set("value2", test*0.643);
      });
        
      row.find("#txtboxvalue2").bind("blur", function(e)   {
          var test=  $("#txtboxvalue2").val();
          // set the required field to the new value.
         model.set("value1", test*1.555);
      });
}
 </text>))
Kind regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Raina
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or