Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Pager Not working
07/03/2011
19:25
Avatar
bhogsett
Cleveland, Ohio, USA
Member
Members
Forum Posts: 19
Member Since:
21/09/2009
sp_UserOfflineSmall Offline

My grid loads data, sorts the data, but will not page.  When the page button is clicked the "Loading" message appers briefly but the data does not change.  The same result, if I manualy change the page number.

In firebug, I can see the request from jQgrid and the response from the server.  The response is properly formatted jSon.

Here is my html:

<script type="text/javascript">
$(document).ready(function(){

 
 jQuery("#wdData").jqGrid({
    url:'../testJson.php?q=2',
    datatype: "json",
    colNames:['ID','Item', 'Value'],
    colModel:[
        {name:'id',index:'id', width:55, hidden: true },
        {name:'item',index:'item', width:490, sortable: true},
        {name:'value',index:'value', width:300}],
    rowNum:20,
    rowList:[10,20,30,40],
    pager: '#pager2',
    sortname: 'item',
    viewrecords: true,
    sortorder: "desc",
    caption:"Weather Display TestTags--Json",
    width:600,
    height:800
    
    });
    jQuery("#wdData").jqGrid('navGrid','#pager2',{edit:false,add:false,del:false});
    

});

</script>
</head>
<body>
<div id ="content"><table id="wdData"></table><div id="pager2"></div> </div>
</body>
</html>

The page itself is at:  http://billhogsett.com/wd/wd2/wd-JQGrid/testJSon2.html

Can someone point me to the error of my ways?

Thanks!

Bill

22/07/2011
19:18
Avatar
CaraK
Member
Members
Forum Posts: 10
Member Since:
14/07/2011
sp_UserOfflineSmall Offline

Hi I had the same problem. Could you resolve this issue?

01/08/2011
22:11
Avatar
CaraK
Member
Members
Forum Posts: 10
Member Since:
14/07/2011
sp_UserOfflineSmall Offline

I still with this problem, the pager don't work. I can see 3 pages but when i press the next page the grid stay in page 1 Confused

Help

02/08/2011
00:40
Avatar
CaraK
Member
Members
Forum Posts: 10
Member Since:
14/07/2011
sp_UserOfflineSmall Offline

Well I have this code in a page aspx

protected string GridUsuarios(string nm, string cd)
    {
        iConn = new System.Data.Odbc.OdbcConnection(ConfigurationManager.AppSettings["ConexionStringMySql"]);
        string SQL = "SELECT id_realizador, upper(nombre), cargo, Case cargo When '1' then 'SUPERVISOR' When '2' Then 'OPERADOR' When '3' Then 'TECNICO' When '4' Then 'CLIENTE' When '5' Then 'SUPERVISOR EXTERNO' When '6' Then 'OPERADOR EXTERNO' Else cargo End, lower(e_mail) FROM t_realizadores WHERE 1";

        if (nm.Trim() != "")
        {
            SQL = SQL + " AND nombre Like '%" + nm.Trim() + "%'";
        }

        if (cd.Trim() != "0")
        {
            SQL = SQL + " AND cargo = '" + cd.Trim() + "'";
        }

        SQL = SQL + " Order By id_realizador";

        iConn.Open();
        oDataSet = new DataSet();
        oAdapter = new OdbcDataAdapter(SQL, (OdbcConnection)iConn);
        oAdapter.Fill(oDataSet);
        iConn.Close();

        List<TraeUsuarios> Listado = new List<TraeUsuarios>();

        for (int i = 0; i < oDataSet.Tables[0].Rows.Count; i++)
        {
            if (oDataSet.Tables[0].Rows[i].ItemArray[1].ToString().Trim() != "")
            {
                Listado.Add(new TraeUsuarios { Id = Convert.ToInt32(oDataSet.Tables[0].Rows[i].ItemArray[0].ToString().Trim()), Nombre = oDataSet.Tables[0].Rows[i].ItemArray[1].ToString().Trim(), CargoId = oDataSet.Tables[0].Rows[i].ItemArray[2].ToString().Trim(), Cargo = oDataSet.Tables[0].Rows[i].ItemArray[3].ToString().Trim(), Email = oDataSet.Tables[0].Rows[i].ItemArray[4].ToString().Trim() });
            }
        }
        return GridUsuariosDatos(((Listado.Count) / 10) + 1, 1, Listado.Count, Listado);
    }

    public string GridUsuariosDatos(int noOfPages, int startPage, int noOfRecords, List<TraeUsuarios> list)
    {
        var gridData = new
        {
            page = startPage,
            total = noOfPages,            
            records = noOfRecords,
            rows = list,
        };

        var jsonSerializer = new JavaScriptSerializer();
        return jsonSerializer.Serialize(gridData);
    }

    public class TraeUsuarios
    {
        public TraeUsuarios()
        {
            Id = 0;
            Nombre = string.Empty;
            CargoId = string.Empty;
            Cargo = string.Empty;
            Email = string.Empty;
        }

        public int Id { get; set; }
        public string Nombre { get; set; }
        public string CargoId { get; set; }
        public string Cargo { get; set; }
        public string Email { get; set; }
    }

And This in the page that i show the grid

jQuery("#grillausers").jqGrid({
                url: 'FetchGrillas.aspx?pvu=GU&nm=&cd=0',
                datatype: 'json',
                mtype: 'POST',
                colNames: ['Id', 'Nombre', 'CargoId', 'Cargo', 'Email'],
                colModel: [
                { name: 'Id', index: 'Id', width: 20, editable: false, sortable: false, editoptions: { readonly: true, size: 5} },
                { name: 'Nombre', index: 'Nombre', width: 250, align: "left", editable: false, sortable: false, size: 100 },
                { name: 'CargoId', index: 'CargoId', width: 50, align: 'left', editable: false, sortable: false },
                { name: 'Cargo', index: 'Cargo', width: 150, align: 'left', editable: false, sortable: false },
                { name: 'Email', index: 'Email', width: 300, align: 'left', editable: false, sortable: false }
            ],
                rowNum: 10,
                rowList: [10, 20],
                pager: '#paginaciongrilla',
                sortname: 'Id',
                viewrecords: true,
                sortorder: "desc",
                jsonReader: { repeatitems: false },
                caption: 'Usuarios'
                , height: 255
                , onSelectRow: function() {
                    var id = jQuery("#grillausers").jqGrid('getGridParam', 'selrow');
                    if (id) {
                        var ret = jQuery("#grillausers").jqGrid('getRowData', id);
                        alert(ret.Id);
                        return false;
                    }
                }
            });

But when i press the next page button i alway return the first page 🙁

Please Help 😛

03/08/2011
17:52
Avatar
Rukbat
USA
Member
Members
Forum Posts: 8
Member Since:
28/07/2011
sp_UserOfflineSmall Offline

Is the response from the server the second page, or is it the first page over and over?  It sounds like a server-side code problem.  The server gets the row numbers the grid wants, and it's the responsibility of the server-side code to get those rows from the database.  In most databases that would be the LIMIT clause (in PHP, you'd use $start = $limit*$page – $limit; for the start and $limit for the liimit.)

04/08/2011
20:51
Avatar
CaraK
Member
Members
Forum Posts: 10
Member Since:
14/07/2011
sp_UserOfflineSmall Offline

the question is how i can send the page number to that server function when i press the next page button?

05/08/2011
15:22
Avatar
Rukbat
USA
Member
Members
Forum Posts: 8
Member Since:
28/07/2011
sp_UserOfflineSmall Offline

jqGrid sends the start record number and number of records to the server.  You tell the database to give you those rows.  There's no reason to write paging code yourself, since jqGrid does that for you.  Just use ' ... LIMIT '.$start.', '.$limit, or whatever your particular database uses (some use "limit to x, y rows", some use "limit x,y", some use other syntax).

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
59 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information