Code: Select all
var count = htmlElement.querySelectorAll("option:checked").length;
Code: Select all
var count = htmlElement.querySelectorAll("option:checked").length;
Code: Select all
var count = document.getElementById("GridId").querySelectorAll("div.selected").length / numberOfGridColumns;
I'm aware of everything you pointed out and I guess I just didn't make myself clear as to what I was asking. I didn't actually want to use the querySelectorAll() method. I was just using that as a native JavaScript example of a one-line method for obtaining the desired information -- i.e., without having to perform my own loop. So, what I was asking is whether Profound has come up with an API for obtaining that information?David wrote:This approach may not work so well, due to details of the Grid widget implementation ...
Yes, I already have my own code using that method but don't like having to do this. Would much rather have an API for it.David wrote:To get the selected row count reliably for any type of subfile loading, you should be able to use this API to check the bound 'selection field' value:
http://www.profoundlogic.com/docs/displ ... ldName+%29
You can call that in a loop by starting at row 1 and incrementing as you go, along with the 'selection field' name. Quit when the API returns null field value.
Code: Select all
/* ================================================================================
countGridRowSelections() returns a count of the number of grid rows currently
selected. The arguments are the grid id and name of
the bound indicator (0/1) type "selection field"
associated with that grid.
*/
wob.countGridRowSelections = function(gridId, selectionFieldName)
{
var mygrid = getObj(gridId).grid, // get reference to grid object
cnt = 0, sel, seqno = 1; // initialize variables
if (mygrid) // if grid exists
{
while (sel = mygrid.getDataValue(seqno, selectionFieldName)) // loop on grid rows
{
if (sel == "1") // if row is selected
{
++cnt; // increment selection count
}
++seqno; // increment row number
}
}
return cnt; // return selection count to caller
}
Would much appreciate it. Thanks.David wrote:We can consider adding one.
Users browsing this forum: No registered users and 4 guests