Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Filter/Find/Sort by display method

1,220 views
Skip to first unread message

Christoph Malherbe

unread,
Jul 9, 2007, 7:56:11 AM7/9/07
to
Hi all,

I've successfully implemented filter/find functionality on a display method
and it looks/feels ALMOST like standard AX. I use a query, containing
multiple datasources, to populate the form's datasource.

I now need to implement sorting by this field as well.

Adjusting the sort criteria on the datasource's query doesn't seem do the
trick.

Has anybody managed to do this?

Best regards,

Christoph

----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.

http://www.microsoft.com/Businesssolutions/Community/NewsGroups/dgbrowser/en-us/default.mspx?mid=4e80c3c4-5e0c-4f76-874c-76beac6897d7&dg=microsoft.public.axapta.programming

kaizen

unread,
Jul 16, 2007, 6:46:18 AM7/16/07
to
Hello Christoph,

That is interesting. Can you share with us how you manage to filter/find
a display method.

Thanks.

Regards,
kaizen (Singapore)

Dynamics Ax Outsource Partner
http://www.axperts-network.com

Christoph Malherbe

unread,
Jul 16, 2007, 7:08:00 AM7/16/07
to
Hi kaizen,

Included in this post is a sample project. Everything between the rows of
asterisks makes up the contents of an AX 4.0 Sp1 .xpo file.

Best of luck!

************************************************************

Exportfile for AOT version 1.0 or later
Formatversion: 1

***Element: QUE

; Microsoft Dynamics Query: Query1 unloaded
;
--------------------------------------------------------------------------------
VERSION 8

QUERY #Query1
PROPERTIES
Name #Query1
Version #6
NextUniqueId #1002
ENDPROPERTIES

METHODS
Version: 3
SOURCE #classDeclaration
#public class QueryRun extends ObjectRun
#{
#}
ENDSOURCE
ENDMETHODS
BLOCKS
BLOCK #CustTrans
PROPERTIES
Name #CustTrans_1
Table #CustTrans
UniqueId #1000
ENDPROPERTIES

FIELDLIST
PROPERTIES
ENDPROPERTIES

ENDFIELDLIST
SORTING
ENDSORTING
LINES
ENDLINES
BLOCKS
BLOCK #CustTable
PROPERTIES
Name #CustTable_1
Table #CustTable
UniqueId #1001
FetchMode #1:1
JoinMode #ExistsJoin
Relations #Yes
ENDPROPERTIES

FIELDLIST
PROPERTIES
ENDPROPERTIES

ENDFIELDLIST
SORTING
ENDSORTING
LINES
ENDLINES
BLOCKS
ENDBLOCKS
ASSOCIATIONS
ASSOCIATION
MASTERFIELD #AccountNum
DETAILSFIELD #AccountNum
ENDASSOCIATIONS
ENDBLOCK
ENDBLOCKS
ENDBLOCK
ENDBLOCKS
ENDQUERY


***Element: FRM

; Microsoft Dynamics Forms unloaded
;
--------------------------------------------------------------------------------
FRMVERSION 5

FORM #Form2
PROPERTIES
Name #Form2
ENDPROPERTIES

METHODS
Version: 3
SOURCE #implementCancelFilter
#void implementCancelFilter()
#{
# ;
#
#
CustTrans_ds.query().dataSourceTable(tableNum(CustTable)).clearRange(fieldNum(CustTable, Name));
#
# CustTrans_ds.executeQuery();
#}
ENDSOURCE
SOURCE #implementFilter
#void implementFilter(CustName _custName)
#{
# QueryBuildRange qbr =
CustTrans_ds.query().dataSourceTable(tableNum(CustTable)).findRange(fieldNum(CustTable, Name));
#
# ;
#
# if (_custName)
# {
# if (qbr)
# {
# qbr.value(queryValue(_custName));
# }
# else
# {
#
CustTrans_ds.query().dataSourceTable(tableNum(CustTable)).addRange(fieldNum(CustTable, Name)).value(queryValue(_custName));
# }
# }
# else
# {
#
CustTrans_ds.query().dataSourceTable(tableNum(CustTable)).clearRange(fieldNum(CustTable, Name));
# }
#
# CustTrans_ds.executeQuery();
#}
ENDSOURCE
SOURCE #implementFind
#void implementFind()
#{
# Object formRun;
# Args args = new Args(formstr(SysFormSearch));
# QueryBuildRange qbr =
CustTrans_ds.query().dataSourceTable(tableNum(CustTable)).findRange(fieldNum(CustTable, Name));
# str findText;
#
# ;
#
# args.record(CustTable::find(CustTrans.AccountNum));
#
# formRun = classFactory.formRunClass(args);
# formRun.field(fieldNum(CustTable, Name));
#
# formRun.run();
#
# formRun.wait();
#
# if (formRun.getText())
# {
# findText = formRun.getText();
#
# if (qbr)
# {
# qbr.value(findText);
# }
# else
# {
#
CustTrans_ds.query().dataSourceTable(tableNum(CustTable)).addRange(fieldNum(CustTable, Name)).value(findText);
# }
# }
# else
# {
#
CustTrans_ds.query().dataSourceTable(tableNum(CustTable)).clearRange(fieldNum(CustTable, Name));
# }
#
# CustTrans_ds.executeQuery();
#}
ENDSOURCE
SOURCE #classDeclaration
#public class FormRun extends ObjectRun
#{
#}
ENDSOURCE
ENDMETHODS
OBJECTBANK
DATASOURCE
OBJECTPOOL
PROPERTIES
Name #CustTrans
Table #CustTrans
ENDPROPERTIES

FIELDLIST
ENDFIELDLIST
ENDOBJECTPOOL
METHODS
Version: 3
SOURCE #init
#public void init()
#{
# ;
#
# super();
#
# this.query(new Query(queryStr(Query1)));
#}
ENDSOURCE
ENDMETHODS
ENDDATASOURCE
ENDOBJECTBANK

JOINS
ENDJOINS

DESIGN
PROPERTIES
ENDPROPERTIES

CONTAINER
CONTROL GRID
;==== controlId:12290, containerId: 0, containerdata: 0
;----------------------------------------------------------
PROPERTIES
Name #Grid
DataSource #CustTrans
ENDPROPERTIES

CONTAINER
CONTROL STRINGEDIT
;==== controlId:12291, containerId:12290, containerdata: 0
;----------------------------------------------------------
PROPERTIES
Name #StringEdit
DataSource #CustTrans
DataMethod #custTableName
ENDPROPERTIES

METHODS
Version: 3
SOURCE #showContextMenu
#public int showContextMenu(int _menuHandle)
#{
# int ret;
# PopUpMenu popUpMenu = PopUpMenu::create(_menuHandle,
this.hWnd());
# int findMenuOption;
# int filterMenuOption;
# int cancelFilterMenuOption;
#
# ;
#
# findMenuOption = popUpMenu.insertItem("Find...");
# filterMenuOption = popUpMenu.insertItem("Filter");
# cancelFilterMenuOption = popUpMenu.insertItem("Remove
filter");
#
# ret = popUpMenu.draw();
#
# switch (ret)
# {
# case findMenuOption :
# element.implementFind();
#
# break;
#
# case filterMenuOption :
# element.implementFilter(this.valueStr());
#
# break;
#
# case cancelFilterMenuOption :
# element.implementCancelFilter();
#
# break;
# }
#
# return ret;
#}
ENDSOURCE
ENDMETHODS
ENDCONTROL

CONTROL STRINGEDIT
;==== controlId:12292, containerId:12290, containerdata: 0
;----------------------------------------------------------
PROPERTIES
Name #CustTrans_AccountNum
DataSource #CustTrans
DataField #AccountNum
ENDPROPERTIES

ENDCONTROL

CONTROL DATEEDIT
;==== controlId:12293, containerId:12290, containerdata: 0
;----------------------------------------------------------
PROPERTIES
Name #CustTrans_TransDate
DataSource #CustTrans
DataField #TransDate
ENDPROPERTIES

ENDCONTROL

CONTROL STRINGEDIT
;==== controlId:12294, containerId:12290, containerdata: 0
;----------------------------------------------------------
PROPERTIES
Name #CustTrans_Voucher
DataSource #CustTrans
DataField #Voucher
ENDPROPERTIES

ENDCONTROL

CONTROL STRINGEDIT
;==== controlId:12295, containerId:12290, containerdata: 0
;----------------------------------------------------------
PROPERTIES
Name #CustTrans_Invoice
DataSource #CustTrans
DataField #Invoice
ENDPROPERTIES

ENDCONTROL

CONTROL STRINGEDIT
;==== controlId:12296, containerId:12290, containerdata: 0
;----------------------------------------------------------
PROPERTIES
Name #CustTrans_Txt
DataSource #CustTrans
DataField #Txt
ENDPROPERTIES

ENDCONTROL

CONTROL REALEDIT
;==== controlId:12297, containerId:12290, containerdata: 0
;----------------------------------------------------------
PROPERTIES
Name #CustTrans_AmountCur
DataSource #CustTrans
DataField #AmountCur
MinNoOfDecimals #Auto
ENDPROPERTIES

ENDCONTROL

ENDCONTAINER

ENDCONTROL

ENDCONTAINER

ENDDESIGN

ENDFORM


***Element: PRN

; Microsoft Dynamics Project : FindfilterOndisplayMethod unloaded
;
--------------------------------------------------------------------------------
PROJECTVERSION 2

PROJECT #FindfilterOndisplayMethod
PRIVATE
PROPERTIES
Name #FindfilterOndisplayMethod
ENDPROPERTIES

BEGINNODE
FILETYPE 0
UTILTYPE 20
UTILOBJECTID 0
NODETYPE 330
NAME #Query1
ENDNODE
BEGINNODE
FILETYPE 0
UTILTYPE 11
UTILOBJECTID 0
NODETYPE 201
NAME #Form2
ENDNODE
ENDPROJECT

***Element: END


************************************************************

elton

unread,
Jul 17, 2007, 4:42:32 AM7/17/07
to
hi Christoph,

How to filter if my display method return a value that computed by 2 fields.
display amount(){
return this.SalesQty -this.OrderQty;
}
I 'd like to filter the records that amount()>0.

Thanks for your help.


0 new messages