在 Jquery - jTable 中创建/更新模式的字段末尾添加自定义按钮,如提交按钮

Add Custom button at end of fields in Jquery - jTable Create/Update mode like submit button

本文关键字:按钮 添加 自定义 字段 提交 jTable Jquery 创建 模式 更新      更新时间:2023-09-26

在jquery- jTable上,我们可以有一些字段和操作。 我需要Jquery JTable按钮("提交"按钮)附近的其他按钮[可能在页面末尾],然后单击后,运行另一个功能。所以这是我的代码:

    $('#RequestSubmitDiv').jtable({
            title: 'newRec',
            paging: false,
            sorting: false,
            selecting:false; 
            selectingCheckBoxes:false,
            selectOnRowClick:false,
            jqueryuitheme:true,
            formCreated:function(event,data){
                 data.form.validationEngine();
            },
            formSubmitting:function(event,data){
               ...
               ...
            },
            formClode: function(d,e){...} ,                
            actions: {
                createAction: '/Adminsec/ManageAssets.aspx/CreateOrUpdate',
           //---not need below
                //listAction: '/Adminsec/ManageAssets.aspx/List',
                //updateAction: '/Adminsec/ManageAssets.aspx/CreateOrUpdate',
                //deleteAction: '/Adminsec/ManageAssets.aspx/Deletes'
  //-!!---Other Button and Action Need ---!!
                CustomAction:{
                  title:'RefreshNew',
                  sorting:false,
                  create:false,
                  edit:false ,
                  list:false ,
                  display:function(data){
                    return '<input type='button' id='MyBtn' onclick='Call_Mehod();>';                              
                   }
                 }
            },
            fields: {
              ID {title:'pk',type:'textarea'} , 
              RequestNO{type:'textarea'},
              description{type:'textarea'}
            }
        });

如何向 Jquery- Jtable 添加一些按钮并调用函数?这些按钮不会在行或列处重复,我的意思是它应该是字段范围之后的一个实例。

也许我误解了,但如果你想在每一行添加一个按钮,你可以使用字段display属性。我创建了一个虚拟字段并添加了显示属性。像这样沉吟:

...
Other: {
    title: 'Other',
    display: function (data) {
       return '<b>test</b>';
    },
    create: false,
    edit: false
}
...

但是,如果要添加常规功能(即表格的单个按钮),则可以查看toolbar属性。

我做了如下。标记<button>class="jtable-command-button"始终是必需的。下一步是图标类,最后是事件。

actions: {
                    title: 'Actions',
                    width: '1%',
                    sorting: false,
                    create: false,
                    edit: false,
                    list: true,
                    display: function (data) {
                        if (data.record) {
                            // This if you want a custom edit action.
                            return '<button title="Edit" class="jtable-command-button jtable-edit-command-button" onclick="alert(' + data.record.id + '); return false;"><span>Edit</span></button>';
                        }
                    }
                }