I have a table with N rows. How can I get the total number of rows present in the table?
I search for a name, and that particular name is in row number X, how can I get the value of that particular row.
You can use .find to solve both of your cases.
To get the table row count:
cy.get("#tableID")
.find("tr")
.then((row) => {
//row.length will give you the row count
cy.log(row.length);
});
To get the value ( index ) of the particular row, you can do something like this.
cy.get("#Table Id")
.find("tr")
.then((rows) => {
rows.toArray().forEach((element) => {
if (element.innerHTML.includes("Your Value")) {
//rows.index(element) will give you the row index
cy.log(rows.index(element));
}
});
});
Additional tip: If you want to select a specific table cell containing a value, you can do this:
cy.get("#customers").find("tr").find("td").contains("Germany");
Note: to get the table row index there can be many other alternative ways. Hope you will figure them out on the go.
Related
My Google Sheets Select statement selects rows from a master sheet of results and then sorts them by time (least amount of time first) ascending.
Some of these results will be entered as DNS and I want them to appear at the end of the time but they appear at the top.
Here is my statement:
Select A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,V,W where not D contains '/' and O is not Null order by P Asc
Column P contains time in HH:mm:ss formatted as duration. If one of the riders is a DNS, they appear at the top of the sort. Unless I sort descending - which is not desired.
With DNS, you probably mean "did not start". The query() function will only accept one data type in a column, and because most of the values in column P are time values, the "DNS" values will return as null. query() sorts null values first.
Try this to sort your data the way you describe:
=sort( { Data!A2:R, Data!Q2:R, Data!V2:W }, Data!P2:P, true )
Then use filter() or query() to remove rows where column D contains a /.
I hope one can help me, I am new in linq,
I have 2 tables name tblcart and tblorderdetail:
I just show some fields in these two tables to show whats my problem:
tblCart:
ID,
CartID,
Barcode,
and tblOrderDetail:
ID,
CartID,
IsCompleted
Barcode
when someone save an order, before he confirms his request,one row temporarily enter into the tblCart,
then if he or she confirms his request another row will be inserted into the tblOrderDetail ,
Now I wanna not to show the rows that is inserted into tblOrderDetailed(showing just temporarily rows which there is in tblCart),
In another words, if there is rows in tblCart with cartID=1 and at the same time there is the same row with CartID= 1 in tblOrderDetail, then I dont want that Row.
All in all, Just the rows that there isnt in tblOrderDetail, and the field to realize this is CartID,
I should mention that I make Iscompleted=true, and with that either we can exclude the rows we do not want,
I did this:
var cartItems = context.tblCarts
.Join(context.tblSiteOrderDetails,
w => w.CartID,
orderDetail => orderDetail.cartID,
(w,orderDetail) => new{w,orderDetail})
.Where(a=>a.orderDetail.cartID !=a.w.CartID)
.ToList()
however it doesn't work.
one example:
tblCart:
ID=1
CartID=1213
Barcode=4567
ID=2
CartID=1214
Barcode=4567
ID=3
CartID=1215
Barcode=6576
tblOrderDetail:
ID=2
CartID=1213
Barcode=4567
IsCompleted=true
with these data it should just show the last two Row in tblCart, I mean
ID=2
CartID=1214
Barcode=4567
ID=3
CartID=1215
Barcode=6576
This sounds like a case for WHERE NOT EXISTS in sql.
roughly translated this should be something like this in LINQ:
var cartItems = context.tblCarts.Where(crt => !context.tblSiteOrderDetails.Any(od => od.CartID == crt.cartID));
If you have a navigation property on cart to reference details (I'll assume it's called Details), then:
var results=context.tblCarts.Where(c=>!c.Details.Any(d=>d.IsCompleted));
I'm trying to show all rows in a jqGrid table. I know I can use rowList to let the user choose how many rows wants to see, but how can I put an option to see all rows? If a put a number like 999999999, it will show all rows because there are less rows, but the user will see that big number as an option and is not too logic.
You can use words instead of numbers in rowList as follows:
rowList:['All','100','500','1000']
Then you have to use your server controller to "convert" that information to a number of rows to show.
I did it like this:
Integer intRows = 0;
if (rows.getClass().equals(String.class) && ((String)rows).equalsIgnoreCase("all")) {
intRows = Integer.MAX_VALUE;
} else {
intRows = Integer.valueOf(rows);
}
So your server will show Integer.MAX_VALUE if user selects "All", or a number of rows it other case.
I think you won't have more than Integer.MAX_VALUE rows in your table, it's such a big number!
I want to persist the column order via localStorage which is working. However, the column chooser gives the order of the columns based on the current order not the original order.
Example:
3 column table where 0 is first, 1 == second, 2 is last column
0,1,2
choose column order to put last column in first, order becomes
2,0,1
choose column order again and put (original last column) back into last and order becomes:
1,2,0
because it resets the column numbers based on current order rather than ORIGINAL order. How to fix this?
onClickButton: function () {
$(this).jqGrid('columnChooser', {
done : function (perm) {
if (perm) {
localStorage["OD_Table_Col_Order"] = perm;
$(this).jqGrid("remapColumns", perm, true);
}
}
});
}
I think that you can find the solution if you would use remapColumns parameter of jqGrid as additional information.
One more way would be to save in localStorage the array of name properties of colModel items instead of the indexes perm.
I have a DataGrid, created programmatically and loaded from ItemFileReadStore.
I want the first column of DataGrid always be sorted in descending order and disabled for user for sorting. Any other column should be available for sorting as a secondary sortable.
I don't want to give users such a powerful(complex and confusing) feature, as sorting by multiple columns, because there are too many columns in my grid.
So, it should be one sortable column for user and another one "already sorted unsortable" column in fact.
Does anyone know how can this be achieved?
Thanks.
To sort the first column add "sortInfo:-1" when you created your object.
To allow sorting the grid from any other columns but not the first you need to overwrite the function canSort.
To create you grid should now look like this .
dijit.grid.DataGrid({
canSort: function (sortInfo) {
if (Math.abs(sortInfo) == 1){
return false;
} else {
return this.inherited("canSort", arguments);
}
},
sortInfo: -1, .....
If you need to sort on more as one column you need dojox.grid.enhanced.plugins.NestedSorting.
http://dojotoolkit.org/reference-guide/1.7/dojox/grid/EnhancedGrid/plugins/NestedSorting.html