0

I have modified this jsfiddle with the code I am using located here

Gets the index of a row in the array

I am wanting grab the row indexes that match the const intersection values. Is there any way to do this? (I need to select the rows that match the intersected values but it do not know how to grab them and then pass them see end of code)

Thanks for any help on this!

Also, here is the jqxGrid API references:

jqxGrid API

Copy & paste these elements into the HTML:

<div id='jqxWidget'>
    <div id="jqxgrid"></div>
</div>
<input type="button" style="margin: 50px;" id="jqxbutton" value="Get displayed rows" />

JavaScript:

var data = new Array();
var firstNames = [34286, 34288, 34293];
var allObjectIDS = [];
var allRowIndexes = [];
var roomsAssignedData = [];
roomsAssignedData = [34288, 34293];
allObjectIDS = []
for (var i = 0; i < 3; i++) {
    var row = {};
    row["firstname"] = firstNames[Math.floor(Math.random() * firstNames.length)];
    data[i] = row;
}
var source = {
    localdata: data,
    datatype: "array"
};
var dataAdapter = new $.jqx.dataAdapter(source, {
    loadComplete: function (data) { },
    loadError: function (xhr, status, error) { }
});
$("#jqxgrid").jqxGrid({
    theme: 'energyblue',
    altrows: true,
    altstep: 2,
    width: 200,
    height: 200,
    source: dataAdapter,
    columns: [{
        text: 'First Name',
        datafield: 'firstname',
        width: 100
    }]
});

$('#jqxbutton').click(function () {
    var rows = $('#jqxgrid').jqxGrid('getrows');
    var rowsB = $('#jqxgrid').jqxGrid('getdisplayrows');
    var rowsCount = rows.length;
    console.log(rowsCount)


    for (var i = 0; i < rowsCount; i++) {
        var valueObjectID = $('#jqxgrid').jqxGrid('getcellvalue', i, "firstname");
        var row = rowsB[i];
        var boundIndex = row.boundindex
        var rowID = row.uid
        allObjectIDS.push(
            row.firstname

        );
        allRowIndexes.push(
            boundIndex,
        );
    }

    console.log("allObjectIDS array")
    console.log(allObjectIDS)
    console.log("allRowIndexes array")
    console.log(allRowIndexes)
    console.log("roomsAssignedData")
    console.log(roomsAssignedData)
    const intersection = allObjectIDS.filter(element => roomsAssignedData.includes(element));
    console.log("intersection")
    console.log(intersection)
    var sortA = roomsAssignedData.sort();
    var sortB = intersection.sort();

    console.log("sortA")
    console.log(sortA)
    console.log("sortB")
    console.log(sortB)
//$('#jqxgrid').jqxGrid('selectrow', value);
//this is where I need to select the rows that match the intersected values but it do not know how to grab them and then pass them
});
2

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.