jQWidgets Forums

jQuery UI Widgets Forums Grid Fetch row data in jqxgrid and post it to a php file

This topic contains 13 replies, has 2 voices, and was last updated by  vsriram92 11 years, 4 months ago.

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

  • vsriram92
    Member

    I saw the demo programs
    1. checked listbox form
    2. checkbox column

    I need the combination of above 2 programs.
    i.e for the grid in “checkbox column” program, I need to have a submit button in addition to it.
    It should display the output as like “checked listbox form” program.

    I tried to learn jqxgrid API and checkbox program. But since Im a newbie, im unable to integrate it.. 🙁


    Peter Stoev
    Keymaster

    Hi vsriram92,

    For CRUD with PHP, see: http://www.jqwidgets.com/jquery-widgets-documentation/documentation/phpintegration/php-server-side-grid-crud.htm. You can submit Grid values only through custom Ajax calls to your server as shown in the help topic.

    Best Regards,
    Peter Stoev

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


    vsriram92
    Member

    Im just asking to add submit button to the program – http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/index.htm?(arctic)#demos/jqxgrid/checkboxcolumn.htm

    Once we click submit button, then the first name corresponding to the checked checkbox must be shown in another div.
    How to do that ?


    Peter Stoev
    Keymaster

    Hi vsriram92,

    By placing just a submit button, you will not submit a column from the Grid. As shown in the sample I posted, you can submit content from the Grid to your server only through Ajax. To get a value of a cell, you can use the Grid’s “getcellvalue” method and by using the Ajax function’s “data” member you can submit that value to your server.

    Best Regards,
    Peter Stoev

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


    vsriram92
    Member

    Ok sir.. But How to get the rowid of the selected checkbox placed inside the grid?
    I can call gridcellvalue method by using that rowid only.


    Peter Stoev
    Keymaster

    Hi vsriram92,

    “getcellvalue” works with a row index i.e 0, 1, 2, etc. Not row ID. Another method – “getselectedrowindexes” returns an array of the indexes of the selected rows and you can also use the “getboundrows” method to get all bound rows of jqxGrid.

    Best Regards,
    Peter Stoev

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


    vsriram92
    Member

    Hi peter…

    I added this code to checkboxcolumn.htm file…
    But it doesn’t work…

    Correct me..

    $("#sendButton").click( function() {
    var selectedrowindexes = $("#jqxgrid").jqxGrid('getselectedrowindexes');
    var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
    // begin update. Stops the Grid's rendering.
    selectedrowindexes.sort();
    // delete the selected rows by using the 'deleterow' method of jqxGrid.
    for (var m = 0; m < selectedrowindexes.length; m++) {
    var selectedrowindex = selectedrowindexes[selectedrowindexes.length - m - 1];
    if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
    var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex);
    var data = $('#jqxGrid').jqxGrid('getrowdata', id);
    $('#string').append('<span class="vat">'+ data +'</span>');
    }
    }
    });

    Peter Stoev
    Keymaster

    Hi vsriram92,

    “getrowdata” works with Bound index, not with Row ID as you can see from the help and api docs.
    You can use “getboundrows” to get the rows array.

    Example for getting the first bound row:

    var boundRows = $("#grid").jqxGrid('getboundrows');
    var boundRow = boundRows[0];

    Best Regards,
    Peter Stoev

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


    vsriram92
    Member
    $("#sendButton").click( function() {
    var selectedrowindexes = $("#jqxgrid").jqxGrid('getselectedrowindexes');
    var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
    selectedrowindexes.sort();
    for (var m = 0; m < selectedrowindexes.length; m++) {
    var selectedrowindex = selectedrowindexes[selectedrowindexes.length - m - 1];
    if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
    var boundRows = $("#jqxgrid").jqxGrid('getboundrows');
    var data = boundRows[0];
    $('#string').append('<span class="vat">'+ data +'</span>');
    }
    }
    });

    When I use this code I get the output as

    [object Object]

    How to get the specific row data ?

    On adding

    var rowID = rowData.uid;

    , I get the output as undefined..


    vsriram92
    Member

    Also the below code don give any output..

    $("#sendButton").click( function() {
    var selectedrowindexes = $("#jqxgrid").jqxGrid('getselectedrowindexes');
    var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
    selectedrowindexes.sort();
    for (var m = 0; m < selectedrowindexes.length; m++) {
    var selectedrowindex = selectedrowindexes[selectedrowindexes.length - m - 1];
    if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
    var boundRows = $("#jqxgrid").jqxGrid('getboundrows');
    var boundRow = boundRows[0];
    var data = $('#jqxGrid').jqxGrid('getrowdata', boundRow);
    var rowID = boundRows.uid
    $('#string').append('<span class="vat">'+ data + rowID +'</span>');
    }
    }
    });

    So pls tell me what to modify in it peter…


    Peter Stoev
    Keymaster

    Hi vsriram92,

    It won’t give output because it is wrong. boundRows is Array. var boundRow = boundRows[0] returns a Row with Key/Value pairs where the Key is the column’s data field and the value is the cell’s value. var rowID = boundRows.uid will return nothing because the Array does not have a member called uid.

    Best Regards,
    Peter Stoev

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


    vsriram92
    Member

    This is my boundRow array

    ShippedDate : Wed Jul 31 1996 05:30:00 GMT+0530 (India Standard Time),
    Freight : 146.06,
    ShipName : Ernst Handel,
    ShipAddress : Kirchgasse 6,
    ShipCity : Graz,
    ShipCountry : Austria,
    uid : 15

    I tried boundrow[ShipName], But it didn work..
    So How to get the ship name from it ?


    Peter Stoev
    Keymaster

    That is probably your bound row, not boundRow array.
    To get the ShipName, write the following:

    option 1 – boundRow.ShipName
    option 2 – boundRow[“ShipName”]

    Best Regards,
    Peter Stoev

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


    vsriram92
    Member

    Thanks peter… At last you made my first Jquery code working.. 🙂
    Sorry for troubling you…

    Since Im a newbie its littlebit confusing and difficult to understand..

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

You must be logged in to reply to this topic.