jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – jsgrid多个自定义控件按钮?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想添加多个自定义控件按钮,以便我可以向按钮添加自定义单击事件.我遇到的问题是只显示删除按钮.我希望每一行都显示编辑和删除按钮.我有以下代码

<script>
    $( document ).ready(function() {
      $("#jsGrid").jsGrid({
           height: "auto",width: "100%",sorting: true,paging: true,autoload: true,pageSize: 10,pageButtonCount: 5,deleteConfirm: "Do you really want to delete your job listing?",controller: {
               loadData: function(filter) {
                   return $.ajax({
                       type: "GET",url: "<?PHP echo site_url('/job/getjobs/'.$this->session->employer_id); ?>",data: filter
                   });
               },},fields: [
               { name: "id",title: "id",type: "text",visible: false,width: 100 },{ name: "title",title: "Title",{ name: "created_on",title: "Created On",{ name: "salary",title: "Salary",{ name: "is_active",title: "Is Active",{ type: "control",width: 100,editButton: false,deleteButton: false,itemTemplate: function(value,item) {
                    var $result = jsGrid.fields.control.prototype.itemTemplate.apply(this,arguments);

                    var $customButton = $("<button>").attr({class: "customGridDeletebutton jsgrid-button jsgrid-edit-button"})
                      .click(function(e) {
                        alert("ID: " + item.id);
                        e.stopPropagation();
                      });

                    return $result.add($customButton);
                },item) {
                  var $result = jsGrid.fields.control.prototype.itemTemplate.apply(this,arguments);

                  var $customButton = $("<button>").attr({class: "customGridEditbutton jsgrid-button jsgrid-delete-button"})
                    .click(function(e) {
                      alert("Title: " + item.title);
                      e.stopPropagation();
                    });

                    return $result.add($customButton);
                }
              }
           ]
       });
    });

</script>

解决方法

我弄明白了:

码:

<script>
    $( document ).ready(function() {
      $("#jsGrid").jsGrid({
           height: "auto",arguments);

                    var $customEditButton = $("<button>").attr({class: "customGridEditbutton jsgrid-button jsgrid-edit-button"})
                      .click(function(e) {
                        alert("ID: " + item.id);
                        e.stopPropagation();
                      });

                   var $customDeleteButton = $("<button>").attr({class: "customGridDeletebutton jsgrid-button jsgrid-delete-button"})
                    .click(function(e) {
                      alert("Title: " + item.title);
                      e.stopPropagation();
                    });

                    return $("<div>").append($customEditButton).append($customDeleteButton);
                    //return $result.add($customButton);
                },}
           ]
       });
    });

</script>

大佬总结

以上是大佬教程为你收集整理的jquery – jsgrid多个自定义控件按钮?全部内容,希望文章能够帮你解决jquery – jsgrid多个自定义控件按钮?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: