【问题标题】:issue in showing pager after reloading the jqxgrid data on click event在单击事件上重新加载 jqxgrid 数据后显示寻呼机的问题
【发布时间】:2015-01-30 14:14:50
【问题描述】:

我正在尝试在单击事件时重新加载网格。这是我的网格代码

var source = {
            datatype: "json",
            datafields: [                     
                        { name: 'sno' },
                        { name: 'bid' },
                        { name: 'city' },                    
                        { name: 'booking_date' },                    
                        { name: 'amount' },                  
                        { name: 'customer_contact' },                    
                        { name: 'user_name' },                   
                        { name: 'trip_type' },
                        { name: 'comments' },
                        { name: 'action' },
            ],
            cache: false,
            url: 'order_details.php?flag=2&start_date='+start_date_param+'&end_date='+end_date_param,              
            data: {
                pagesize:50
            },
            root: 'Rows',
            //sortcolumn: 'area',
           // sortdirection: 'asc',
           beforeprocessing: function (data) {
                source.totalrecords = data[0].TotalRows;
            }
        };
        dataadapter = new $.jqx.dataAdapter(source);

        // initialize jqxGrid
        $("#jqxgrid").jqxGrid(
        {
            width: 1100,
            source: dataadapter,
            theme: 'classic',
            autoheight: true,
            pageable: true,
            pagesize:50,
            enablebrowserselection: true, 
            selectionmode: 'singlecell',
            //sortable:true,
            virtualmode: true,
            rendergridrows: function (params) {
                return params.data;
            },
            columns:
            [   
                { text: 'No', datafield: 'sno', width: 30 },
                { text: 'Booking Id', datafield: 'bid', width: 90, align: 'center',cellsAlign: 'center' },
                { text: 'City', datafield: 'city', width: 170 },
                { text: 'Car Book Date', datafield: 'booking_date', width: 100, align: 'center',cellsAlign: 'center' },
                { text: 'Amount', datafield: 'amount', width: 60, align: 'right',cellsAlign: 'right' },
                { text: 'Customer Contact', datafield: 'customer_contact', width: 205 },
                { text: 'User Name', datafield: 'user_name', width: 125 },
                { text: 'Trip Type', datafield: 'trip_type', width: 160},
                { text: 'Comments', datafield: 'comments', width: 80, align: 'center',cellsAlign: 'center'},
                { text: 'Action', datafield: 'action', width: 80, align: 'center',cellsAlign: 'center'},
            ]
        });

        // event handling on select of date range and click on button show 
        $("#btn_show").on("click", function (e) {
            e.preventDefault();
            var start_date_param = $("#start_date").val();
            var end_date_param = $("#end_date").val();
            source.url = 'order_details.php?flag=2&start_date='+start_date_param+'&end_date='+end_date_param; 
              dataadapter.dataBind();
        });

单击“btn_show”按钮时,我可以从第 0 页获取数据,但如果我在第 4 页,则在单击事件后,我的网格寻呼机仅保留在第 4 页,并且数据显示在第 0 页。如果我点击下一页,那么它会从第 0 页跳转到下一页,即第 5 页。
为什么 jqxgrid 在单击事件后没有在 dataadapter.dataBind() 调用上重置其记录的开始索引和记录的结束索引值?
我是否需要使用任何其他功能来重新加载我的完整网格??

【问题讨论】:

    标签: jqxgrid


    【解决方案1】:

    我认为如下:

    $("#jqxgrid").jqxGrid('gotopage', 0);
    

    应该替换

    dataadapter.dataBind();
    

    在您的代码中。

    【讨论】:

    • 它只是去page0,但我想重新加载新的网格内容,点击事件后不会发生这种情况。需要用别的东西
    • gotopage 转到第 0 页并执行“updatebounddata”。我建议您实现适配器的 formatData 回调并将您的自定义参数放在那里,gotopage 调用就足够了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多