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,803

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

  • Suggested answer
    How to create row number in Grid Form?
    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.
  • Martin Dráb Profile Picture
    Martin Dráb 231,305 Most Valuable Professional on at
    RE: How to create row number in Grid Form?

    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.

  • fajar Profile Picture
    fajar 3,803 on at
    RE: How to create row number in Grid Form?

    @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
    Martin Dráb 231,305 Most Valuable Professional on at
    RE: How to create row number in Grid Form?

    @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.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to create row number in Grid Form?

    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

  • fajar Profile Picture
    fajar 3,803 on at
    RE: How to create row number in Grid Form?

    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
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: How to create row number in Grid Form?

    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.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,489 Super User 2025 Season 1 on at
    RE: How to create row number in Grid Form?

    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.

  • Martin Dráb Profile Picture
    Martin Dráb 231,305 Most Valuable Professional on at
    RE: How to create row number in Grid Form?

    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?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans