jQWidgets Forums

jQuery UI Widgets Forums Grid jqxgrid initrowdetails mysql

This topic contains 2 replies, has 2 voices, and was last updated by  Hristo 6 years, 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • jqxgrid initrowdetails mysql #101585

    dan123
    Participant

    Hi i am trying to use the initrowdetails function in the jqxgrid, and i am trying to figure out a workaround to add like a Total quantity value based on store_name retrieved from either a ajax call or something else alternative.

    Problem:
    I am just not sure how to return my sql query value into this
    ‘var totalquantity = “<div style=’margin: 10px;’><b>Total Quantity:</b> ” + insert value here + “</div>”;’

    Code:
    var initrowdetails = function (index, parentElement, gridElement, datarecord) {
    //var id = datarecord.uid.toString();
    var tabsdiv = null;
    var information = null;
    tabsdiv = $($(parentElement).children()[0]);

    if (tabsdiv != null) {
    information = tabsdiv.find(‘.information’);
    var title = tabsdiv.find(‘.title’);
    var container = $(‘<div class=”row noselect” style=”margin: 5px;”></div>’);
    container.appendTo($(information));
    var leftcolumn = $(‘<div id=”storeinventory” class=”col-md-3″></div>’);
    container.append(leftcolumn);
    var dataFields3 = [
    { name: ‘id’, type: ‘number’},
    { name: ‘product_name’, type: ‘string’},
    { name: ‘quantity’, type: ‘number’},
    { name: ‘price’, type: ‘number’},
    { name: ‘total’, type: ‘string’},
    { name: ‘store_name’, type: ‘string’},
    ];
    var row = $(‘#jqxgrid’).jqxGrid(‘getrowboundindex’, args.rowindex);
    var id = $(“#jqxgrid”).jqxGrid(‘getrowdata’, row)[‘store_name’];

    var source =
    {
    datatype: “json”,
    datafields: dataFields3,
    url: ‘totals.php’,
    id: ‘id’,
    data: {store_name: id},
    root: ‘Rows’,
    beforeprocessing: function (data) {
    source.totalrecords = data[0].TotalRows;
    },

    };

    var dataAdapter = new $.jqx.dataAdapter(source);

    var totalquantity = “<div style=’margin: 10px;’><b>Total Quantity:</b> ” + Totalcount.quantity + “</div>”;
    var totalproducts = “<div style=’margin: 10px;’><b>Total Products:</b> ” + Totalcount.product_name + “</div>”;
    $(leftcolumn).append(totalquantity);
    $(leftcolumn).append(totalproducts);
    }
    }

    jqxgrid initrowdetails mysql #101589

    dan123
    Participant

    Here is mysql to get row count and i want to echo this query in ‘var totalquantity’
    if (isset($_GET[‘store_name’]))
    {
    $query = “SELECT count(*) FROM inventory WHERE addedbyuser='”.$_SESSION[“username”].”‘ AND store_name='” .$_GET[‘store_name’]. “‘”;
    $result = mysql_query($query) or die(“SQL Error 1: ” . mysql_error());
    echo $result;
    }

    jqxgrid initrowdetails mysql #101628

    Hristo
    Participant

    Hello dan123,

    You should check the result of the request is it correct (totalrecords).
    Also, I saw in your code where you use “args.rowindex” but this args variable does not have declaration before that.
    Check this, please? Also, is there any error message in the console?

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

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

You must be logged in to reply to this topic.