質問

I am using handsontable for creating a CRUD (create read update delete) interface for my databases which now require these two things.

  1. Able to create/update/delete rows/cells which are changed (and not the whole data set)
  2. Able to load more data from database (as new records are added) or refresh changed rows

-

Part 1 (Solved) - http://jsfiddle.net/p7KwM/

So I added a field name modified as timestamp (INT) to database so that data can be refreshed at user side by checking this modified field, and it is INT so that TZ value can be added as per user. See here http://demo.mgvz.com/.twilio/loader.pl and now I am stuck at that I want to modify this INT to add TZ value and to covert it to date-time format within handsontable. (Can't do it server side) If it can be modified by way of function within handsontable, else the only option is to modify it before giving it to handsontable.

Part 2 (any help appreciated)

Second, I have to add rows which are created on server and update rows which are changed on server, without effecting other unchanged rows, (a user might be editing other rows), and to maintain sorting while adding the rows.

Can anyone guide me about it.

Thanks

役に立ちましたか?

解決

To update data, have a look at setDataAtCell method:

setDataAtCell (row: Number, col: Number, value: Mixed, source: String (Optional)) 

To add new rows created on server, have a look at the alter method:

alter ('insert_row', index: Number, amount: Number (Optional), source: String (Optional))

You can find more detailed description of those 2 methods here

So to update something that was changed on server:

$container.handsontable('setDataAtCell', rowIndex, colNumber, "New Value");

And to add new:

var rowIndex = 2; //You will need to determine this to maintain sorting, or set to null to add as last row.
var numberOfRows 1; //Only adding one row at a time
$container.handsontable('alter', 'insert_row', rowIndex, colNumber);
//After row is added you can update the values of each column using setDataAtCell as per above
$container.handsontable('setDataAtCell', rowIndex, 1, "FirstName");
$container.handsontable('setDataAtCell', rowIndex, 2, "LastName");
//One line for each column or have a look at the setDataAtCell method for alternative option

You may enocunter issues if the user is for example editing values that need updating, or what happens if you add a row while user is editing?

I hope any of this helps

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top