2014-09-01 79 views
5

我有问题,在bootgrid重装阿贾克斯数据(http://www.jquery-bootgrid.com/刷新jQuery中BootGrid不行

我已经成功准备网格以显示在所有的,但如果我添加项目到DB,我想使电网的重载。

我的代码是现在这个(缩短):

var grid; 
$(document).ready(function() { 
    grid = initGrid(); 
}); 
function initGrid() { 
    var local_grid = $('#clients-grid').bootgrid({ 
     "ajax": true, 
     "url": "/client/grid", 
     "formatters": { 
      "commands": function(column, row) { 
       return "<button type=\"button\" class=\"btn btn-default command-edit\" data-row-id=\"" + row.id + "\"><span class=\"glyphicon glyphicon-pencil\"></span></button> " + 
         "<button type=\"button\" class=\"btn btn-default command-delete\" data-row-id=\"" + row.id + "\"><span class=\"glyphicon glyphicon-trash\"></span></button> " + 
         "<button type=\"button\" class=\"btn btn-default command-mail\" data-row-id=\"" + row.id + "\"><span class=\"glyphicon glyphicon-envelope\"></span></button>"; 
      }, 
      "tooltips": function(column,row) { 
       return '<span type="button" class="content-popover" title="'+row.name+'" data-content="'+row.content+'">Najeďte myší pro zobrazení obsahu</span>'; 
      }, 
      "clientname": function(column,row) { 
       return row.name; 
      } 
     } 
    }).on("loaded.rs.jquery.bootgrid", function() { 
     $('.content-popover').popover({ 
      trigger: 'hover', 
      html: true, 
      placement: 'right', 
      content: $(this).attr('data-content') 
     }); 
     grid.find(".command-edit").on("click", function(e) { 
      editClient($(this).data('row-id')); 
     }).end().find(".command-delete").on("click", function(e) { 
      var id = $(this).data('row-id'); 
      if (confirm('Opravdu smazat klienta s ID: '+$(this).data("row-id")+'?')) { 
       deleteClient($(this).data('row-id')); 
      } 
     }).end().find(".command-mail").on("click", function(e){ 
      mailClient($(this).data('row-id')); 
     }); 
    }); 
    return local_grid; 
} 

所以对电网的变量是全球和地方有访问.. 但功能重装这里记载:http://www.jquery-bootgrid.com/Documentation#methods没有工作,我有阿贾克斯的参数集on true

有什么建议吗?

谢谢,对不起,我的英语

回答

2

所以我自己,我不使用grid.reload()方法,但阿贾克斯后保存,方便地调用完成这个任务:-)

$('button[title=Refresh]').click(); 
8

你尝试:

$('#grid-data').bootgrid('reload'); 

对我来说,AJAX请求加载

+0

谢谢迈克尔。你是一个拯救生命的人。为我省了很多搜索力:) – 2015-07-21 09:20:28

+0

页面没有保留。 – arhuaco 2015-10-05 15:02:15

0

更改以下脚本jquery.bootgrid.js片段

Grid.prototype.reload = function() 
    { 
     this.current = 1; // reset 
     loadData.call(this); 
     return this; 
    }; 

变化:

Grid.prototype.reload = function(current) 
{ 
    this.current = (current !== 'undefined') ? current : 1; 
    loadData.call(this); 

    return this; 
};