jQuery UI Widgets Forums Grid Get the Specific rows of the Grid

This topic contains 3 replies, has 2 voices, and was last updated by  Dimitar 10 years, 6 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Get the Specific rows of the Grid #51298

    Akshar AK
    Participant

    the code $(“#GridName”).jqxGrid(‘getrows’); will give me the entire grid data. is there a way to get only the specific rows? Suppose the above code gets me 50 rows of data. but i want only 20 based on particular value of the row. how to achieve it?

    Get the Specific rows of the Grid #51300

    Dimitar
    Participant

    Hello Akshar AK,

    You can iterate through the array of all rows (with for) and check for a particular value (with if). The rows which comply to your requirement you can add to a new array.

    Best Regards,
    Dimitar

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

    Get the Specific rows of the Grid #51309

    Akshar AK
    Participant

    i have an array of the indexes in which all rows the data is modified. I want the exact same resultset of $(“#GridName”).jqxGrid(‘getrows’); but only with the rows of the indexes in the array. Can you plz show me how to do it? Also i would like to ask if i have a liscense then is there a seperate forum to ask questions or same?

    Get the Specific rows of the Grid #51352

    Dimitar
    Participant

    Hi Akshar AK,

    Here is an example. The desired rows are the only ones left in allRows after the iteration. The array myArray holds the indexes of the rows to leave.

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="../../scripts/jquery-1.10.2.min.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.filter.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.sort.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.edit.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxpanel.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcalendar.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxdatetimeinput.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.pager.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxnumberinput.js"></script>
        <script type="text/javascript" src="../../scripts/demos.js"></script>
        <script type="text/javascript" src="../../jqwidgets/globalization/globalize.js"></script>
        <script type="text/javascript" src="generatedata.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                var data = generatedata(10);
                var source =
                {
                    localdata: data,
                    datafields:
                    [
                        { name: 'name', type: 'string' },
                        { name: 'productname', type: 'string' },
                        { name: 'available', type: 'bool' },
                        { name: 'date', type: 'date' },
                        { name: 'quantity', type: 'number' },
                        { name: 'price', type: 'number' }
                    ],
                    datatype: "array"
                };
    
                var dataAdapter = new $.jqx.dataAdapter(source);
    
                $("#jqxgrid").jqxGrid(
                {
                    width: 685,
                    source: dataAdapter,
                    showfilterrow: true,
                    filterable: true,
                    pageable: true,
                    autoheight: true,
                    editable: true,
                    selectionmode: 'singlecell',
                    columns: [
                      { text: 'Name', columntype: 'textbox', filtertype: 'textbox', datafield: 'name', width: 115 },
                      { text: 'Produkt', filtertype: 'textbox', datafield: 'productname', width: 220 },
                      { text: 'Datum', datafield: 'date', columntype: 'datetimeinput', filtertype: 'date', width: 210, cellsalign: 'right', cellsformat: 'd' },
                      { text: 'Qt.', datafield: 'quantity', columntype: 'numberinput', filtertype: 'textbox', cellsalign: 'right', width: 60 },
                      { text: 'Preis', datafield: 'price', columntype: 'numberinput', filtertype: 'textbox', cellsformat: "c2", cellsalign: 'right' }
                    ]
                });
    
                var myArray = new Array(0, 5, 8, 9);
    
                $("#getRows").click(function () {
                    var allRows = $("#jqxgrid").jqxGrid('getrows');
                    for (var i = allRows.length - 1; i >= 0; i--) {
                        if (myArray.indexOf(i) == -1) {
                            allRows.splice(i, 1);
                        };
                    };
                });
            });
        </script>
    </head>
    <body class='default'>
        <div id="jqxgrid">
        </div>
        <button id="getRows">
            Get rows</button>
    </body>
    </html>

    If you have purchased a license, you can send your queries to support@jqwidgets.com.

    Best Regards,
    Dimitar

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

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

You must be logged in to reply to this topic.