Search code examples
asp.net-mvc-3asp.net-mvc-4teleriktelerik-gridtelerik-mvc

Get updated value in another cell using Telerik MVC grid OnSave method


I want modified cell value in another cell in OnSave clientevent.

My Scenario :

I have simply two columns in my TELERIK MVC Grid MinVal & MaxVal, I want to check if Min value does not exceed Max value provided and Max value can't be less then Min. value in OnSave client event but I am not able to get modified value of MinVal & MaxVal inside OnSave client event.

I have default value for MinVal = 100 & MaxVal = 200. Step 1 : I have change my MinVal value to 105. Step 2 : Now when I want to change my MaxVal value to 100( which is invalid).but inside my OnSave client event e.dataItem.MinVal I always get 100. but instead I want updated value 105 without submitting changes to server.

Can anyone suggest me best way to achieve this.

Thanks in advance.


Solution

  • You need to simply get the values of the textboxes during the Save event. Here is an example.

    function onSave(e) {
       var minValue = $("#MinVal").val();
       var maxValue = $("#MaxVal").val();
    
       if (minValue >= maxValue)
          alert("Min value equal to or exceeds Max value.");
          e.preventDefault();
          return false;
    }