I have a Wijmo Grid where the first column is Id.
$("#logGrid").wijgrid({
loaded: loadedHandler,
columns: [
{ headerText: "Id", dataType: "string", dataKey: "Id", visible: false },
{ headerText: "Foo", dataType: "datetime", dataKey: "Foo", },
{ headerText: "Bar", dataType: "string", dataKey: "Bar" }
],
data: datasource
});
I want to get the row number, for the row with the same Id as the parameter (defaultSelectedLogId).
I have tryed with:
var getRowNumber = function (defaultSelectedLogId) {
var rowNumbertest = $("#logGrid").closest('tr').prevAll().length;
var rowNumbertest2 = $("#logGrid tr").prevAll().length; // Result: 7 (total row numbers)
var rowNumber = $("#logGrid tr").cell("id=[" + defaultSelectedLogId + "]").prevAll().length;
var rowNumber2 = $("#logGrid tr id=[" + defaultSelectedLogId + "]").cell.column().dataKey.prevAll().length;
var rowNumber3 = $("#logGrid tr").cell.column().dataKey.prevAll().length;
return rowNumber;
}
I should be simple. 1) Iterate the rows. 2) Find the row with Id equals to the giving parameter. 3) return the row number.
EDIT: Inspecting the table with firebug, it have the structure like this:
<tbody class="ui-widget-content wijmo-wijgrid-data">
<tr class="wijmo-wijgrid-row ui-widget-content wijmo-wijgrid-datarow" role="row">
<div class="wijmo-wijgrid-innercell">56259</div>
This should return the zero based index of the row
var rowNumber = $('div:contains(' + defaultSelectedLogId + ')').closest('tr').index();
EDIT: It works now, but must use single quote instead of double quote.