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

[Solved] Incell edit send all data to server

3 Answers 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jonisan
Top achievements
Rank 1
Jonisan asked on 22 May 2012, 08:25 PM
Hello .. I have a grid with 12 normal input rows and a "Total" row . The edit is in cell . 
See Image : http://imageshack.us/photo/my-images/96/gridzo.jpg/ 
When one cell is edited , the "Total" cell of that row updates he's value :

       var grid = $("#PlantBudgetGrid").data('tGrid');
        grid.data[12].TotalHical += value;
        grid.$rows()[12].childNodes[1].innerText = grid.data[12].TotalHical;

The problem is that if the user inserts a value in the 12 row (the Total) then I have to add the Total/12 value to all
cells from that column. When I submit the changes .. to the controller .. I only get the changed values that the
user inserted .. not the ones that I calculated and edited . 

Solutions : When I insert  the value to the last row (Total) I do a post to the server , save new values in the database and rebind the grid
Problem for this : The update will make the "Cancel Changes" button useless

Is there a more easy way to do the jQuery insert of that in grid cell and set the dirty flag so this cells will be sent to the server on submit?


3 Answers, 1 is accepted

Sort by
0
Jonisan
Top achievements
Rank 1
answered on 23 May 2012, 10:16 AM
One more possibility is that I get the onSubmitChanges event and try to change the value that is passed to the controller :

function submitChanges(value) {
        var data = $("#PlantBudgetGrid").data('tGrid').dataSource._data;
        value.updated = data;
        return value; 
    }

Problems in this  : Only my calculated values are in the .dataSource._data; That I can hack with no problem
     The controller receives only the changed rows .. how do I change the value of return?

A easy and basic solution will be to add the dirty flag to all the grid in the "submitChanges" and that will make the controller
recive all the grid on updates .. How do I add the dirty flag to all the rows?
0
Jonisan
Top achievements
Rank 1
answered on 23 May 2012, 11:20 AM
Ok .. to simplify the problem : 
 How to I add the dirty flag to all the grid cells, and when the SubmitChanges event
will come all the grids values will send to the controller.

 $(e.cell).find(".t-dirty")  has a remove method , but I think that is only for visual effect ..
0
Jonisan
Top achievements
Rank 1
answered on 23 May 2012, 11:25 PM
OK , I implemented the call to the server when the total value is edited , so the cancel button is now half useless .. but OK ..
Can someone tell me :
   1 -   How can I make that when I start editing "inCell" in a specific cell , the value in that cell is selected , like it happens
in a "inline"  editing ..
   2 -   Is there a fix to the showing of dirty flag (red triangle) when you don't change the value ? 
the  $(e.cell).find(".t-dirty").remove()  called in the OnSave event  is not working :(
Tags
Grid
Asked by
Jonisan
Top achievements
Rank 1
Answers by
Jonisan
Top achievements
Rank 1
Share this question
or