Author Topic: A problem with ASP.net Webforms  (Read 3902 times)

sunshineme

  • Newbie
  • *
  • Posts: 3
    • View Profile
A problem with ASP.net Webforms
« on: March 08, 2016, 08:40:09 pm »
Hi,
I have a problem about my grid, the first time when i get data into PQ grid from a asp.net web form ,it succeeded and displays data.But  when i change some paramters in url and send url to  server again,my call is never reaching the server,and it executes a function in  pqgrid.dev.js,the name of the function is "fn._setOptions",then it returns. I would appreciate if you could tell me where I am going wrong.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6264
    • View Profile
Re: A problem with ASP.net Webforms
« Reply #1 on: March 15, 2016, 11:51:42 pm »
A test case/ jsfiddle might be useful to identify the issue.

Anyway there are options postData and postDataOnce to send the parameters along with the url which could be used.

sunshineme

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: A problem with ASP.net Webforms
« Reply #2 on: March 16, 2016, 09:35:55 pm »
     Thanks for your repliy!
     Actully,I have two tabs and a grid container on a WebForm,The two tabs are stand for users gender,one is Male,and anthor is Female,when i click the "Male" tab,i hope get user's info who's gender is Male,and when i switch to the "Female" tab,i want to get user's info who's gender is Female.
    That means i must change paramter's value and send it to server to get what i want.Now my situation is that i tried the method that you suggested me to use the option of postData and send it,but i having not any luck,the grid load data only once...,when i change and click other tab,my call can never reaching the server.
    What i want is that when i switch these tabs,grid can send request to server just like the grid's paging function.I also get some info from http://paramquery.com/pro/tutorial,it seems that i must use the mehtod named "refreshDataAndView"  if i want to reload data from server(loction='romote').And i also tried it in v1.1.3 and it did,so I was really confused,does PqGrid no longer supported this situation in v2.0.4 ? Or any other way i can use to solve my problem ?
    Here is my JS code:
   
Code: [Select]
     function ListGrid(obj) {         
             var _sex=obj;
            //paramters
            var _postData = {"Sex": _sex };
            //url
            var _url = "UserInfo.aspx?action=GridBindList";
            //colM:grid title
            var _colM = [
                { title: "UserID", width: 100, dataType: "integer", dataIndx: "UserID" },
                { title: "UserName", width: 100, dataType: "string", dataIndx: "UserName" },
                {
                    title: "Sex", width: 150, dataType: "integer", dataIndx: "Sex",
                    render: function (ui) {
                        var rowData = ui.rowData;
                        var value = rowData["Sex"];
                        if (value == "0") {
                            return "Female";
                        }
                        else{
                            return "Male";
                        }
                    }
                }
            ];
            PQLoadGrid("#grid_paging", _url, _colM, _postData, 20);
        }
        /*
       a function that it is used to get data into PQ grid from server
       obj_ID:Container ID
    */
        function PQLoadGrid(obj_ID, _url, _colM, _postData, _pageSize) {
            var dataModel = {
                location: "remote",
                paging: "remote",
                dataType: "JSON",
                method: "GET",
                postData: _postData,
                url: _url + "&a=" + new Date(),
                getData: function (dataJSON, textStatus, jqXHR) {
                    return { curPage: dataJSON.curPage, totalRecords: dataJSON.totalRecords, data: dataJSON.data };
                }
            }
            var grid = $(obj_ID).pqGrid({
                width: 900,
                height: 400,
                collapsible: false,
                dataModel: dataModel,
                colModel: _colM,
                freezeCols: 0,
                wrap: true,
                hwrap: false,
                numberCell: { resizable: true, width: 30, title: "No" },
                oddRowsHighlight: true,
                columnBorders: true,
                pageModel: { type: "remote", rPP: _pageSize, rPPOptions: [20, 50, 100] },//, strRpp: "{0}",
                editable: false       
            });
        }
   
   And html code as below:
   
Code: [Select]
      <div onclick="ListGrid(0)">Female</div>
      <div onclick="ListGrid(1)">Male</div>
      <div id="grid_paging" style="margin-top: 1px;"></div>
   
  Looking forward to your reply !

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6264
    • View Profile
Re: A problem with ASP.net Webforms
« Reply #3 on: March 20, 2016, 01:54:38 pm »
refreshDataAndView() works fine in 2.0.4

I understand that colModel and grid remains the same for both parameters ( male and female ).
There is no need to recreate the grid and write so much code when you just need to send a parameter to the server.

It's a simple 2 step process:

Set the postData parameter. $grid.pqGrid( 'option', 'postData' , value );

Call refreshDataAndView()

And check browser network console to troubleshoot how parameters are being send and what response you get from the server.

sunshineme

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: A problem with ASP.net Webforms
« Reply #4 on: March 21, 2016, 08:16:44 pm »
Thanks for your tips,I think i know how to solve it . :)