【问题标题】:In handsontable - convert number to date by function and load refresh more data在handsontable - 按功能将数字转换为日期并加载刷新更多数据
【发布时间】:2013-07-03 23:24:10
【问题描述】:

我正在使用 handsontable 为我的数据库创建一个 CRUD(创建读取更新删除)接口,现在需要这两件事。

  1. 能够创建/更新/删除rows/cells which are changed(而不是整个数据集)
  2. 能够从数据库load more data(添加新记录时)或refresh changed rows

-

第 1 部分(已解决)-http://jsfiddle.net/p7KwM/

所以我在数据库中添加了一个字段名称modified as timestamp (INT),以便可以通过检查这个修改的字段在用户端刷新数据,它是INT,以便可以根据用户添加TZ值。请参阅此处http://demo.mgvz.com/.twilio/loader.pl 和现在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。 (服务器端不行)如果可以通过handsontable中的函数进行修改,否则唯一的选择是在将其提供给handsontable之前对其进行修改。

第 2 部分(感谢任何帮助)

其次,我必须add rows which are created on serverupdate rows which are changed on server,而不影响其他未更改的行(用户可能正在编辑其他行),并在添加行时保持排序。

谁能指导我。

谢谢

【问题讨论】:

    标签: javascript handsontable


    【解决方案1】:

    要更新数据,请查看setDataAtCell 方法:

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

    要添加在服务器上创建的新行,请查看alter 方法:

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

    你可以找到这两种方法的更详细的描述here

    所以要更新服务器上更改的内容:

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

    并添加新的:

    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
    

    如果用户正在编辑需要更新的值,或者如果您在用户编辑时添加一行,您可能会遇到问题?

    希望对你有帮助

    【讨论】:

    • 谢谢,我会试试这个alter,并添加多行并保持结果排序。到目前为止,我已经关闭了排序;)
    猜你喜欢
    • 2015-04-16
    • 1970-01-01
    • 1970-01-01
    • 2019-06-10
    • 1970-01-01
    • 1970-01-01
    • 2021-04-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多