jQWidgets Forums

jQuery UI Widgets Forums Grid html, php search form – load data into jqxgrid

This topic contains 1 reply, has 2 voices, and was last updated by  Martin 6 years, 9 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • kathyl
    Participant

    I have a basic search form for a computer inventory system using php, with a mysql db storing all the data. The client needs to be able to search the data and return to a grid. Here is part of the form, simplified:

    ....
    <div id = "searchForm">
    <form class="form" action="results.php" method="post">
    
    <label for "name">Workstation Name</label>
    <input name="name" id="name" type="text">
    
    <label for "name">Model</label>
    <input name="model" id="model" type="text">
    ......
    <submit button here>
    ......

    The form is submitted fine. In “results.php” I load all the grid js files as well as “results.js”. I also have a div with an id of “summaryGrid”. In results.js I have the following:

    var source=
    {
         datatype: "json",
         url: "processSearch.php",
         data: { "name": name, "model":model },
         datafields: [
              { name: 'name', type: 'string' },
              { name: 'model', type: 'string' },
         ........ ],
         type: "POST"
         cache: false,
         root: 'Rows'
    };
    
    console.log("loading");   // just to make sure
    
    var summaryDataAdapter = new $.jqx.dataAdapter(source, { loadError: function(xhr, status, error) { alert("error"); } });
    
    $("#summaryGrid").jqxGrid(
    {
         source: summaryDataAdapter,
         virtualmode: true,
         columns.....
    });

    in “processSearch.php” the very first thing I do is grab the data posted:

      $name = $_POST['name'];
      $model = $_POST['model'];

    but these values are blank. They are filled in at the original form. I thought the “data” section of the source was where I passed variables to the source url – is this wrong? When I view “results.php” with Web Developer Tools, I see the form data of name and model filled in with the correct information, so I’m not sure where I am going wrong. Any help would be appreciated.


    Martin
    Participant

    Hello kathyl,

    From what you have explained I understand that you make the post request from your form and send the name and model values from there. In this case, the grid has nothing to do with the request. Why do you make a post request from the grid’s dataAdapter? It would be better if you can provide a larger example.

    Also, can you explain where the “name” and “model” variables in the source’s data property in your results.js are defined?

    I would also suggest you to look at our Documentation for Server Side Processing with PHP.

    Best Regards,
    Martin

    jQWidgets Team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.