jQWidgets Forums

jQuery UI Widgets Forums Grid JqxGrid Paging problem

This topic contains 3 replies, has 2 voices, and was last updated by  Hristo 8 years ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • JqxGrid Paging problem #93790

    Kapil
    Participant

    I am using jqxgrid in MVC.net project. On my page I have date range control, submit button and jqx grid. when page loaded the all controls works proper, but when I change the date range and submit the page if database returns 0 records it do not change the grid paging (total number of records).
    This problem do not occur when database return more than 0 record. I am using jqx.dataAdapter callback method to bind the grid.

    this problem only occur when page is reloaded and have 0 records. Grid shows no rows but in paging the total number of record remains same.

    function ConfigurEventAdapter()
    {
    eventSource = {
    datatype: “json”,
    datafields: [
    { name: ‘MLId’, type: ‘int’ },
    { name: ‘Id’, type: ‘string’ },
    { name: ‘MSN’, type: ‘string’ },
    { name: ‘OccuredTime’, type: ‘date’ },
    { name: ‘RestoredTime’, type: ‘date’ },
    { name: ‘MLName’, type: ‘string’ },
    { name: ‘EventName’, type: ‘string’ },
    { name: ‘Phase’, type: ‘string’ },
    { name: ‘Duration’, type: ‘string’ },
    { name: ‘Direction’, type: ‘string’ },
    { name: ‘Depth’, type: ‘string’ },
    { name: ‘OccuredTimeTicks’, type: ‘string’ },
    {name:’EventCode’,type:’int’},
    {name: ‘OccuredTimeSerialzed’, type: ‘string’ },
    {name: ‘RestoredTimeSerialzed’, type: ‘string’ }
    ],
    url:’@Url.Action(“action1”, “controller1”)’,
    root: ‘Events’,
    beforeprocessing: function(data)
    {
    eventSource.totalrecords = data[0].TotalRows;
    },
    sort: function()
    {
    $(“#GrdEvents”).jqxGrid(‘updatebounddata’);
    }
    };

    eventAdapter = new $.jqx.dataAdapter(eventSource, {
    loadServerData: function (serverdata, source, callback) {
    if (LoadEventDatadisabled==true)return;
    $(“.pageLoading”).show();
    $.ajax({
    dataType: source.datatype,
    type:’POST’,
    url: source.url,
    data: serverdata,
    success: function (data, status, xhr) {

    for (var i=0;i< data.Events.length;i++)
    {
    data.Events[i].OccuredTime=converToJsDate( data.Events[i].OccuredTime);
    if (data.Events[i].RestoredTime!=null)
    data.Events[i].RestoredTime=converToJsDate( data.Events[i].RestoredTime);
    }
    callback({ records: data.Events ,totalrecords:data.TotalRows});
    },
    complete:function(){
    $(“.pageLoading”).hide();
    }
    });
    }
    });
    }

    JqxGrid Paging problem #93813

    Hristo
    Participant

    Hello kapiljain,

    It is normal to not be able to change page when you have 0 records.
    Another side, if you expect to have some records in this case when you filter by a concrete date range, this will be strange.
    Could you tell is there any error message?

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    JqxGrid Paging problem #93825

    Kapil
    Participant

    Hi Hristo,

    Thanks for the reply. No there is no error message. But first time if you have some records then it set page size accordingly but when you again submit the page and get 0 records then what is the problem to set 0 of 0 records in paging. If you can empty the grid on 0 records then you should also set paging accordingly.

    
    function ConfigurEventAdapter1()
            {
                eventSource = {
                    datatype: "json",
                    datafields: [
                        { name: 'MLId', type: 'int' },
                        { name: 'Id', type: 'string' },
                                 { name: 'MSN', type: 'string' },
                                 { name: 'OccuredTime', type: 'date' },
                                 { name: 'RestoredTime', type: 'date' },
                                 { name: 'MLName', type: 'string' },
                                 { name: 'EventName', type: 'string' },
                                 { name: 'Phase', type: 'string' },
                                 { name: 'Duration', type: 'string' },
                                 { name: 'Direction', type: 'string' },
                                  { name: 'Depth', type: 'string' },
                    { name: 'OccuredTimeTicks', type: 'string' },
                    {name:'EventCode',type:'int'},
                    {name: 'OccuredTimeSerialzed', type: 'string' },
                    {name: 'RestoredTimeSerialzed', type: 'string' }
                    ],
                    url:'@Url.Action("action")',
                root: 'Events',
                beforeprocessing: function(data)
                {
                    eventSource.totalrecords = data[0].TotalRows;
                },
                sort: function()
                {
                    $("#GrdEvents").jqxGrid('updatebounddata');
                }
            };
    
            eventAdapter = new $.jqx.dataAdapter(eventSource, {
                loadServerData: function (serverdata, source, callback) {
                    if (LoadEventDatadisabled==true)return;
                    $(".pageLoading").show();
                    $.ajax({
                        dataType: source.datatype,
                        type:'POST',
                        url: source.url,
                        data: serverdata,
                        success: function (data, status, xhr) {
    
                            for (var i=0;i< data.Events.length;i++)
                            {
                                data.Events[i].OccuredTime=converToJsDate( data.Events[i].OccuredTime);
                                if (data.Events[i].RestoredTime!=null)
                                    data.Events[i].RestoredTime=converToJsDate( data.Events[i].RestoredTime);
                            }
                            callback({ records: data.Events ,totalrecords:data.TotalRows});
                        },
                        complete:function(){
                            $(".pageLoading").hide();
                        }
                    });
                }
            });
        }
    JqxGrid Paging problem #93870

    Hristo
    Participant

    Hello kapiljain,

    Usually, when there is no data to display (with turned on paging mode) it will show ‘0-0’ records.
    This is the normal behavior.

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.