SmartGWT: ListGrid should grow only as per the number of records - smartgwt

I am using ListGrid in SmartGWT.
I don't want to set height of grid in advance as I dont know the number of records in the DataSource.
So, the requirement is:
If there are less than 10 records, grid's height would be in proportion with the number and if number of records are greater than 10, I will use pagination.

Never Mind. I found one such example here:
http://www.smartclient.com/smartgwt/showcase/#grid_autofit_rows

Related

How do I create a list of non-repeating cells/numbers in Google Sheets?

I’m trying to emulate Minesweeper in Google Sheets, and for this I want to create a second map adjacent to the first with all of the correct values already in it. To randomize bomb position, I need a list of random numbers or cells(cells would be preferable). However, I cannot figure out how to do this without ending up repeating numbers. The result would ideally be a vertical array of cell coordinates. Thank you!
Answer
The following formula should produce the result you desire:
=SORTN(FLATTEN(MAKEARRAY(10,10,LAMBDA(row,col,ADDRESS(row,col)))),20,,RANDARRAY(100),)
In =MAKEARRAY, change the first 10 to adjust how many rows to randomly choose from, or the second 10 to adjust how many columns to choose from. The value in =RANDARRAY must be equal to the product of the number of rows and the number of columns. (e.g. in the above example, 10*10=100).
Change the 20 to adjust how many randomly chosen values to return.
Explanation
=MAKEARRAY is used to generate an array of every possible row and column combination. It accepts a =LAMBDA, which in this case is just the =ADDRESS function. The first two arguments of =MAKEARRAY determine how large the array should be, which is why changing them adjusts how many rows/columns to randomly pick from.
Then, the result of =MAKEARRAY is squashed into a single column using the =FLATTEN formula.
Finally, the entire thing is sorted randomly using =SORTN combined with =RANDARRAY. =SORTN also limits the number of results that are returned dependent on its second argument, which is why changing it adjusts how many results are returned.
If you want information on how to "freeze" the value of =RANDARRAY so it doesn't recalculate each time you change something, check out this question by player0.
Functions used:
=MAKEARRAY
=LAMBDA
=ADDRESS
=FLATTEN
=SORTN
=RANDARRAY

Conditional formatting at row level

I have 2000 rows of cost price data. In each row, I would like to apply a color scale to quickly highlight cost prices (from low to high). However, I would like the color scale comparison logic each time to be applied within a specific row. So row 12 data should not be compared to row 13 data for instance. How can I do this without creating 2000 rules stipulating each row?
I have done it for the first row as below:
D3:BL3
However, when I try $D3:$BL2000 and hit "Done" the $ signs just disappear meaning the formatting logic isn't applied at row level but all rows (so e.g. row 4 is compared to e.g. row 100).
You can't have a conditional formatting with scale color row by row with Google Sheets option. You can simulate it with the help of MIN, MAX and QUARTILE. Here you have an example:
=(D1=MAX($D1:$Z1))*(D1<>"")
=(D1>QUARTILE($D1:$Z1,3))*(D1<>"")
=(D1>QUARTILE($D1:$Z1,2))*(D1<>"")
=(D1>QUARTILE($D1:$Z1,1))*(D1<>"")
=(D1>MIN($D1:$Z1))*(D1<>"")
=(D1=MIN($D1:$Z1))*(D1<>"")
PS: remember to sort accordingly the rules. In the top the highest values (in green in my example) and in the bottom the lowest values
PPS: you could do something similar with the help of RANK or LARGE/SMALL, depending on your data

How to format the first X rows based on sort order?

I have a google sheet that calculates a score for each row based on numeric values in the different columns. I then sort it by the calculated score, high to low. Now I want to conditionally format (bold) the first X rows in the sheet based on that sort order.
Does anyone have any suggestions on how to achieve that? I've been googling for hours now, but no joy.
Thanks!
It should be something like this:
=rows(A$1:A1)<=10
for first 10 rows

Google Sheet - How to calculate subtotal including future insertions

How to calculate the total of a row ? as well whenever requried I will keep add more rows in the sheet. according to sheet's row insertion i require to update the total as well.
at present I use this formula : =SUM(B1:$20) - But not works.
see the screen shot, the 100 inserted later but the total not updated.
With your existing setup, use
=sum(B$1:B23)
then as new rows are added above the Totals row, it will change to
=sum(B$1:B24) etc.
=SUM(B:B)
Can be used to sum a complete column. Unfortunately, you would have to move other things out of the way.
Using menu "Data", you can select a range to be named, and then re-define the range, as items get added.

DB grid - can I display titles in the first row, not the first column?

I want to show MIN(), AVG(), MAX() for 5 measurements.
Given my screen real-estate, it woudl be much better to display my DG grid vertically than horizntally.
I would like to have a DB grid with 2 columns and 15 rows, rather than vice-versa.
But how would I get the text into the first coumn (e.g "Measurement 1 MIN()")? I would much prefer to use a DB grid, rather than a table of 1 x 15 with 15 TLabels to the left of it, but I don't want to store the "column (actually row) titles" in my database.
I hope that I described this clearly - please ask for clarification if not - and that someone can help.
A DBGrid displays the data from a data source. If you want the output to change, change the data - this means you have to do the pivot in your query instead. (I gave you a search term with the bold text, BTW; you want to pivot the data. I can't provide any more info, because a) you didn't say what database you're using, and b) that would be a separate question not related to Delphi.)

Resources