How to find Selected Row's count?


I can loop through in Clicked method as below,

for (inv = InventTable_ds.getFirst(true) ? InventTable_ds.getFirst(true) : InventTable_ds.cursor(); inv; inv = InventTable_ds.getnext())


but before going through this loop, i want to find how may recoreds are selected on Grid.

How to accomplish this task?


Mehul Thacker

Hello Mehul,

You can get the count of the number of records of the form’ s datasource shown on the form’s grid after the form is opened by the method numberOfRowsLoaded() on the form’s datasource:

public int numberOfRowsLoaded()

int numOfDSRecs;


numOfDSRecs = InventTable_ds.numberOfRowsLoaded();

Hi Shankar,

I have used this method, it gives total row count on grid!

i need Selected row count, could you suggest any othor approch?


Mehul Thacker

void clicked()
FormDataSource fds;
Common common;
int counter;

fdS = InventTable_DS;
for (common = fdS.getFirst(true) ? fdS.getFirst(true) : InventTable_DS.cursor(); common; common = fdS.getNext())

Hi Fabricio,

I think this is the simplest way to get Selected row count, but this will lead to TWO FOR loops in code, one specially to get Selected row count & another for logic purpose!!

I think there should be some another way to reach at Selected row count…!


Mehul Thacker

Hi Mehul!

I’m new in DAX, and my English is too bad …

select COUNT(RecId) from TableName where …

counter= TableName.RecId

It isn’t good for you?

If I don’t understand your question, then sorry! [:)]

I think there is no other way to do that , as fabrico suggested. Rather than using the same loop for two times use a map and insert the recid into that, so that you can even implement the remaining business logic in a class by using that map.

Hi Zoltan,

This will not give Selected Row Count insted it will result in LoadedRowCount.

Hi Zoltan,

This will not give Selected Row Count insted it will result in LoadedRowCount.

Hi Kranthi,

Ya, i didnt find any other way to do this.

And in case of MAP,

if i go with MAP then also Second loop will be needed to process MAP items one by one

so this will not reduce any code!!! there should be something to process selected items on the form!!!

it is very ugly that we are not able to get “selected rows count” straight a way! :frowning:

You need to process them, to know the count. Why do you want to know the count before processing?

Why do you think of reducing the code? Are you facing any bottlenecks in the code execution?

What exactly you are doing by selecting them?

I want to show progress bar while processing items, so to set progressbar count i need how many number of rows user has selected!

no i am not facing any bottlenecks in code execution but as good programming there should be one loop only to process items & any how we shuold get Selected Row count directly.!

You can get the number of in a grid selected rows by using


hope this helps


Max Dobbelstein


i want show record when i am onelye selecteds how can i write a code .could u any ideas plz share me.

Hi there this might solve your problem

fsd = formdatasource

(fds.recordsMarked().lastIndex() > 1)

the recordsMarked returns an array with the selected records and the lastIndex method get’s the index of the last record in the array.

Kind regards,