web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to create row number in Grid Form?

(1) ShareShare
ReportReport
Posted on by 3,805

Hi all..

i have custom form with filter by date and group like this picture.

1401.1111.jpg

i want to add one new column for line number or row number in the left column Reksadana.

So, this result like this.

3333.jpg

And this is if i filter from date 1/17/2017.

8357.2222.jpg

and, i want result like this picture below.

2061.4444.jpg

Can i do it?

Please help me explain more for this case.

Thanks master.

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    What logic should be used for generating these numbers? Is the value No field always corresponding to the order in the grid, so mere reordering will assign different numbers to the same records? (We already know that you want filtering to assign different numbers). If so, what's the value of this field? What business problem is it addressing?

  • André Arnaud de Calavon Profile Picture
    301,035 Super User 2025 Season 2 on at

    Hi PIL,

    What is the reason for this row number? Usually a row number would be identifying a certain record. Now you want to change the row number based on a filter. I don't see any benefit for having such a requirement.

    This would be possible to achieve with use of a temporary table where you store the row numbers and a reference to your real table. Export to excel would also be possible. Then you can also easily create row numbers.

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    If you would add a new field to all these datasources and populate the value based on some sequencing, that can be done.

    However, your expectation is not really feasible if you would like to do it on-the-fly. AX typically loads 20 or 25 records into a buffer (unless you have a higher resolution screen, so more rows can fit in the grid), and you will not be able to determine how many records exist beforehand due to for example Filtering, so display method for returning this number is not going to work the way you expect.

  • fajar Profile Picture
    3,805 on at

    Thanks all..

    i think, i can get line number in form like row number in visual studio (expression : =RowNumber("DataSetName")).

    so, if i have 10 record in screen, i can get number from 1-10.

    based on Filter just for get how many record selected based on filter Date or Group.

    so, if i have 20 record in grid form, i can get number 1-20.

    and if i have 5 record, i can get line number 1-5 like row number in visual studio.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi PIL,

        You can create a integer field, for that you can write code for line number.  By using recid we can count the records in a form.

    public void insert()
    {
        ItemReference       itemReferenceLoc;

       ;
        select count(RecId) from itemReferenceLoc;
        this.LineNum = itemReferenceLoc.RecId + 1;

        super();
    }

    try this it may help you.

    Thanks,

    Suresh

  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    @PIL: So, what business problem is your solution going to solve? I somehow fail to see any advantage (and I you would avoid spending time with implementing something like that), therefore I would like to understand your scenario.

    @Crispin, Suresh: As I understand, we're talking about displaying records in a grid, not about creating new records. And if you stored a line number in database, it would be fixed and it wouldn't meet the requirement. Remember, filtering the data should assign new row numbers. Your solution would make sense only if you used a temporary table and always regenerate the content every time when users filter or reorder records.

  • fajar Profile Picture
    3,805 on at

    @Crispin, Suresh: Yes, Martin right. my problem about displaying record in a grid, not creating new record for get line number.

    @Martin : I can't solve this problem. But, no problem, this case not required in my form. I just want to create like in expression RowNumber in visual studio. But, if i can't apply in grid form, no problem.. i will finished this discuss.

    Thanks very much all.

  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    In my opinion, you started from the wrong direction. Instead of understanding what users need and then designing a solution that solves the problem, you take a technical solution and don't ask whether it's solves anything. If it doesn't bring any business value, doing it is just a waste of resources for both development and maintenance and therefore it shouldn't be approved. "I just want" simply isn't a sufficient reason.

  • Suggested answer
    Community member Profile Picture
    2 on at
    i have just tried a solution and it works fine,
    you can try :
    create integer field in your data source: lineNo 
    create the following method in your form class or data source class:

    public void setLineNo()
            {
                myFormDataSource myDataSource;
                int64 lineNo = 1;
                myDataSource=myFormDataSource_ds.getFirst();
                while(myDataSource)
                {
                    myDataSource.LineNo = lineNo;
                    myDataSource= myFormDataSource_ds.getNext();
                    lineNo++;
                }
            }
    call the method we just created in executeQuery method after super,
    and in write and delete methods call executeQuery method,

    this would work fine with newly created and deleted records in addition to control filters work fine too.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans