Hello,
I have been searching this question for days and i could not find any answer. My question is:
I have 2 data sources in my form. And i have a grid. This data sources are joined to each other with inner join. I have fields of both Data Source on my grid. Now i want to sort this grid with following order:
ds1.Name
ds1.Surname
ds2.ExamDate
The grid Data Souce is ds1.
How can i sort with this way?
Thanks a lot;
*This post is locked for comments
Thanks Martin,
This was exactly what i needed.
badiyev, you're right, it doesn't seem to work with addSortField(). Use addOrderByField() instead.
Put this code to form's init() below super:
tb2_ds.queryBuildDataSource().addOrderByField(fieldNum(tb2, SomeDate)); tb2_ds.queryBuildDataSource().addOrderByField(fieldNum(tb2, SomeField)); tb1_ds.queryBuildDataSource().addOrderByField(fieldNum(tb1, RecId));
Tested on my box; it generates the right T-SQL code and (of course) returns expected data.
You could create a temporary table with an index that matches your field order, populate the records from the joined datasources, and use addSortIndex:
msdn.microsoft.com/.../querybuilddatasource.addsortindex.aspx;MSPPError=-2147217396
This is the only way probably that you could use to get it working.
Martin,
When i use addSortField(), it only sorts for the field i provided latest.
For example: I use:
On init() of first ds:
this.queryBuildDataSource().sortClear();
ds2_ds.query().dataSourceTable(tableNum(tb2)).addSortField(fieldNum(tb2, SomeDate));
ds2_ds.query().dataSourceTable(tableNum(tb2)).addSortField(fieldNum(tb2, SomeFIeld));
this.query().dataSourceTable(tableNum(tb1)).addSortField(fieldNum(tb1, RecId));
Here, only sort one is by table 1.recid . I want it to be sorted, first by SomeDate, then by SomeField, then by recid.
Best regards.
addSortField() does seem to be the answer. If you say it's not what you want, tell us why.
Nobody replied because just saying "The question is what i am looking for" doesn't explain anything.
Martin, i am still facing with this problem, can you please suggest a solution?
Best of Regards.
The question is what i am looking for.
What are you looking for ?
hello ievgen,
Thanks for your suggestion and reply, but unfortunately this is not what i am looking for.
Hi badiyev,
Take a look at this community thread community.dynamics.com/.../127335
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156