簡體   English   中英

在jQuery BootGrid中重新加載不起作用

[英]Reload in jQuery BootGrid not work

我在bootgrid中重新加載ajax數據有問題( http://www.jquery-bootgrid.com/

我已成功准備網格顯示,但如果我將項目添加到數據庫,我想重新加載網格。

我的代碼現在是這個(縮短):

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不工作,我的ajax參數設置為true

有什么建議?

謝謝,抱歉我的英語

你試過了嗎:

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

對我來說,加載了ajax請求

所以我自己完成了這個任務:-)

我不使用grid.reload()方法,但在ajax保存后,輕松調用:

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

在腳本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;
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM