I am creating a form in a job using
Form form;
FormRun formRun;
FormBuildDesign formBuildDesign;
FormBuildDataSource formBuildDataSource;
form = new Form();.
formBuildDataSource = form.addDataSource("Table");
formBuildDesign = form.addDesign("Design");
formBuildDesign.widthMode(1);
formBuildDesign.heightMode(1);
form.design().caption("Caption");
I am adding a grid to the form by
formBuildGridControl = formBuildDesign.addControl(FormControlType::Grid,"Table Grid");
and than fields (they are named F1, F2, …) to this grid by
for(ii = 1; ii < 5; ii++)
{
formBuildGridControl.addDataField(formBuildDataSource.id(),fieldName2Id(tableName2id("Table"), strFmt("F%1",ii)));
}
Form is created, grid is added and visible but when I try to sort by a field I get
Invalid sort field type.
and I do not see filter function.
What I need to do to have sorting and filtering available?
I am doing it in Dynamics AX 2012 R2.
Are your fields of type String
with size Memo
?
Sorting by such fields raises exactly that error due to the fact that sorting by this data type is not possible.
Try setting one of this fields to a limited length e.g. 20 and try it again with this field.