jQWidgets Forums

jQuery UI Widgets Forums Grid Problem with checkall on jqxGrid If selectionmode: 'checkbox'

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 11 years, 6 months ago.

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

  • fearbuster
    Participant

    Hi Sir,

    I am using the check-all functionality in jqxGrid by selectionmode: ‘checkbox’ and my problem is it checked all that is not display in the Grid(means that will be appear in next page).I only want to check only that are appear in the grid that time so please suggest me what should i do and there is also problem that check on single check is too slow.

    My Demo Code:-

    <script language=”javascript” type=”text/javascript”>
    $(document).ready(function () {
    var theme = getDemoTheme();

    // prepare the data
    var data = new Array();

    var firstNames =
    [
    “Andrew”, “Nancy”, “Shelley”, “Regina”, “Yoshi”, “Antoni”, “Mayumi”, “Ian”, “Peter”, “Lars”, “Petra”, “Martin”, “Sven”, “Elio”, “Beate”, “Cheryl”, “Michael”, “Guylene”
    ];

    var lastNames =
    [
    “Fuller”, “Davolio”, “Burke”, “Murphy”, “Nagase”, “Saavedra”, “Ohno”, “Devling”, “Wilson”, “Peterson”, “Winkler”, “Bein”, “Petersen”, “Rossi”, “Vileid”, “Saylor”, “Bjorn”, “Nodier”
    ];

    var productNames =
    [
    “Black Tea”, “Green Tea”, “Caffe Espresso”, “Doubleshot Espresso”, “Caffe Latte”, “White Chocolate Mocha”, “Cramel Latte”, “Caffe Americano”, “Cappuccino”, “Espresso Truffle”, “Espresso con Panna”, “Peppermint Mocha Twist”
    ];

    var priceValues =
    [
    “2.25”, “1.5”, “3.0”, “3.3”, “4.5”, “3.6”, “3.8”, “2.5”, “5.0”, “1.75”, “3.25”, “4.0”
    ];

    // generate sample data.
    var generatedata = function (startindex, endindex) {
    var data = {};
    for (var i = startindex; i < endindex; i++) {
    var row = {};
    var productindex = Math.floor(Math.random() * productNames.length);
    var price = parseFloat(priceValues[productindex]);
    var quantity = 1 + Math.round(Math.random() * 10);

    row[“id”] = i;
    row[“firstname”] = firstNames[Math.floor(Math.random() * firstNames.length)];
    row[“lastname”] = lastNames[Math.floor(Math.random() * lastNames.length)];
    row[“productname”] = productNames[productindex];
    row[“price”] = price;
    row[“quantity”] = quantity;
    row[“total”] = price * quantity;

    data[i] = row;
    }
    return data;
    }

    var source =
    {
    datatype: “array”,
    localdata: {},
    totalrecords: 1000000
    };

    // load virtual data.
    var rendergridrows = function (params) {
    var data = generatedata(params.startindex, params.endindex);
    return data;
    }

    var totalcolumnrenderer = function (row, column, cellvalue) {
    var cellvalue = $.jqx.dataFormat.formatnumber(cellvalue, ‘c2’);
    return ‘<span style=”margin: 6px 3px; font-size: 12px; float: right; font-weight: bold;”>’ + cellvalue + ‘</span>’;
    }

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

    $(“#jqxgrid”).jqxGrid(
    {
    width: 670,
    autoheight: true,
    source: dataAdapter,
    theme: theme,
    virtualmode: true,
    pageable: true,
    sortable: true,
    groupable: true,
    filterable: true,
    selectionmode: ‘checkbox’,
    rendergridrows: rendergridrows,
    columns: [
    { text: ‘Id’, datafield: ‘id’, width: 50 },
    { text: ‘First Name’, datafield: ‘firstname’, width: 100 },
    { text: ‘Last Name’, datafield: ‘lastname’, width: 100 },
    { text: ‘Product’, datafield: ‘productname’, width: 180 },
    { text: ‘Quantity’, datafield: ‘quantity’, width: 70, cellsalign: ‘right’ },
    { text: ‘Unit Price’, datafield: ‘price’, width: 70, cellsalign: ‘right’, cellsformat: ‘c2’ },
    { text: ‘Total’, datafield: ‘total’, cellsrenderer: totalcolumnrenderer, width: 100, cellsalign: ‘right’ }
    ]
    });
    $(“#jqxgrid .jqx-grid-column-header [role=’checkbox’]”).on(‘mousedown’, function (event) {
    //var s = 50;

    //alert(“ghgh”);
    if($(“#jqxgrid .jqx-grid-column-header [role=’checkbox’]”).jqxCheckBox(‘checked’))
    $(“#btn”).hide();
    else
    $(“#btn”).show();

    });
    });
    function s() {
    var rows = $(“#jqxgrid”).jqxGrid(“selectedrowindexes”);
    var selectedRecords = new Array();
    for (var m = 0; m < rows.length; m++) {
    var row = $(“#jqxgrid”).jqxGrid(“getrowdata”, rows[m]);
    selectedRecords[selectedRecords.length] = row;
    }

    }

    </script>

    Thanks,

    Fearbuster


    Peter Stoev
    Keymaster

    Hi Fearbuster,

    The Grid’s ‘checkAll’ checkbox checks All Rows within the Grid. It is not possible to modify the behavior for checking only the rows on the current page.

    Best Regards,
    Peter Stoev

    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.