Author Topic: Rpp options - only page refresh loads data, not on page load.  (Read 4397 times)

stelco

  • Newbie
  • *
  • Posts: 10
    • View Profile
Rpp options - only page refresh loads data, not on page load.
« on: September 01, 2014, 10:24:22 pm »
Hi, I have a working grid with my JSON data being read from a remote .json file.  The issue I have is that the data doesnt load (display) on page load, it only loads (displays) after selecting an Rpp option from the drop down.  Can anyone suggest how I would go about displaying the data on page load...does the initial Rpp option need to automatically refresh or something?

            rPP: 20,
            rPPOptions: [1, 10, 20, 30, 40, 50, 100, 500, 1000],
            curPage: 1,

Here is my complete code:

Code: [Select]
<script type="text/javascript">
    $(function () {
        var colM = [

                    { title: "Model", width: 300, dataIndx: "Model" },
                    { title: "Repayments", width: 100, dataIndx: "Repayments" },
                    { title: "Term", width: 100, dataIndx: "Term" },
                    { title: "CapID", width: 100, dataIndx: "CapID" },

        ];

        var dataModel = {
            location: "remote",
            sorting: "local",
            paging: "local",
            dataType: "JSON",
            method: "GET",
            sortIndx: 2,
            sortDir: "up",
            rPP: 20,
            rPPOptions: [1, 10, 20, 30, 40, 50, 100, 500, 1000],
            curPage: 1,
            getUrl: function () {
                return { url: "js/vehicles.json" }
            },
            getData: function (dataJSON) {
                return { data: dataJSON };
            }
        }

        var grid1 = $("div#grid_paging").pqGrid(
            {
            width: 700, height: 600,
            dataModel: dataModel,
            colModel: colM,
            title: "Car Models",
            resizable: true,
            columnBorders: true,
            //freezeCols: 2
            });
 
    });
</script>

    <div style="margin:10px" id="grid_paging"></div>

stelco

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Rpp options - only page refresh loads data, not on page load.
« Reply #1 on: September 02, 2014, 05:38:42 pm »
Can anybody advise about this please?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Rpp options - only page refresh loads data, not on page load.
« Reply #2 on: September 02, 2014, 06:36:16 pm »
The reason for your issue is difficult to tell by looking at your code. No you don't need to do any refresh of rPP

Put a breakpoint in getData callback and see when the method is called and what is the argument value i.e., dataJSON.

stelco

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Rpp options - only page refresh loads data, not on page load.
« Reply #3 on: September 05, 2014, 12:48:51 am »
Hi,

please see the following video.  The GET request just keeps looping: http://screencast.com/t/wMcj4Qbvt


stelco

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Rpp options - only page refresh loads data, not on page load.
« Reply #4 on: September 07, 2014, 08:55:12 pm »
I appear to have fixed this.  It was the sort Index.  It works without using sortIndx or selecting a column heading.  All data loads on page load now.

Code: [Select]
        var dataModel = {
            location: "remote",
            sorting: "local",
            paging: "local",
            dataType: "JSON",
            method: "GET",
           // sortIndx: "CapID",
            sortDir: "down",
            rPP: 20,
            rPPOptions: [1, 10, 20, 30, 40, 50, 100, 500, 1000],
            curPage: 1,
            getUrl: function () {
                return { url: "js/vehicles.json" }
            },
            getData: function (dataJSON) {
                return { data: dataJSON };
            }
        }