【问题标题】:SlickGrid + jQuery Dialog Edit FormSlickGrid + jQuery 对话框编辑表单
【发布时间】:2014-03-09 15:26:21
【问题描述】:

我有一个 SlickGrid onClick 事件连接以打开一个 jQuery 对话框,这样当用户单击某个单元格时,我的 dataView 中的某些字段和值会填充对话框。一切正常,但我很难将表单数据保存回网格。我正在关注这个example,但我使用的是dataView,所以我不确定是否需要进行一些更改。这部分代码会触发,但是当对话框关闭时,dataView 不会使用表单数据进行更新。我缺少一段代码吗?谢谢

$modal.find("[data-action=save]").click(function () {
    grid.getEditController().commitCurrentEdit();
});

【问题讨论】:

    标签: jquery slickgrid jquery-dialog


    【解决方案1】:

    我不确定这是否是正确的做法,但这是我利用有限的 jQuery 知识和Wiki for Data Views 能够解决的问题

    // find the button on the jQuery dialog and use this click event
     $('.ui-dialog-buttonset').find("[data-action=save]").on('click', function () {
    
        //these are the IDs for the inputs on my dialog
        var startDate = $('#dialog-StartDate').val();
        var dueDate = $('#dialog-DueDate').val();
        var lbsForJob = $('#dialog-LbsForJob').val();
    
        //I have a data attribute on my save buton that has the unique ID
        var dialogId = $('#editRowDialogSave').data('id');
    
        // per the wiki for data views, update the data view row
        var item = dataView.getItemById(dialogId);
        item['LbsNeededForJob'] = lbsForJob;
        item['StartDate'] = startDate;
        item['DueDate'] = dueDate;
        dataView.updateItem(dialogId, item);
    
    });
    

    【讨论】:

      猜你喜欢
      • 2014-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多