jqGrid - Is it possible to get object properties ondblClickRow?

130 Views Asked by At

I have the following jqGrid:

enter image description here

I make an AJAX call to display elements on that grid. I wanted to show more items on the grid (same tab) and made another AJAX call.

So, I created 2 arrays. The first array stores the result of Ajax Call 1, the second array stores the result of Ajax Call 2.

I concatenated these arrays and displayed them on the grid:

var test3 = test1.concat(test2);
thegrid.addJSONData(test3);

So far so good, the only problem is, that when I want double click the item on the grid, it can only use the same path for every item, meaning that it can open only 1 form and not different ones.

That's because when clicking the grid, it calls this function:

ondblClickRow: function (rowid, iRow, iCol, e) {
    onDoubleClickGrid(rowid, iRow, iCol, e, divname, listname);
}

Here's the entire function:

function onDoubleClickGrid(rowid, iRow, iCol, e, divname, listname, useFormToOpen) {

    var rowData = $("#" + divname).getRowData(rowid);
    var curID = rowData.Id;
    var useForm = "EditForm.aspx";

    if (checkNull(useFormToOpen)!="") {
        useForm = useFormToOpen;
    }

    var curPath = "/MM/Lists/" + listname;
    // var curPath = "/nderungsantrag/Lists/" + listname;
    var url = curPath + "/" + useForm + "?ID=" + curID;
    openInDialog(dlgWidth, dlgHeight, true, true, true, url);
}

I tried working with flags, but these won't work here because the objects are all in the merged array, and it can't differentiate them.

Is it possible to get the object values of the element that was clicked ondblClickRow? Because then I could use a for loop and check for the properties of the object. Depending on what property it has, I could change the path. Or is there another way to accomplish this?

1

There are 1 best solutions below

0
On BEST ANSWER

The ondblClickRow has a parameter event (the 4 one). Here you can get the element like this (if I understand correct the requierment):

ondblClickRow : function (rowid, iRow, iCol, e) {
    var target = e.target || e.srcElement; // this is what you need
    ....
}

Your curPath is a combination of one constant value and one variable

var curPath = "/MM/Lists/" + listname

If listname variable does not change during double click the row you always will have the same curPath. I do not see if you change it when the row is double clicked.