I am trying to add a edit method to my grid from my data source in the form. I have the following code for the edit method:
edit boolean markLine(
boolean set,
Datasource _datasource,
boolean _mark
)
{
if (set)
{
if (!_mark)
{
if (selectedLines.exists(_datasource.RecId))
{
selectedLines.remove(_datasource.RecId);
}
}
else
{
selectedLines.insert(_datasource.RecId,_datasource.recVersion);
}
}
return selectedLines.exists(_datasource.RecId);
}
I then drag that into a grid which has the datasource specified in it and contains other fields from that datasource. Yet, when I try to use it in the grid, it is not possible to check the box.
I am using a view for my data source, not a table. I am not sure if this is the reason for it or if there is something else that is the problem. Any idea what the problem could be here?
Thanks in advance.
AllowEdit on the data source is true.
Ok, I checked around some more and found the following in the AX documentation about views
Views are read-only. The data fields and tables that a view uses cannot be updated from that view.
Therefore, edit methods will not work because views cannot be edited in the first place.
A workaround for this is to override the mouseDblClick method in the grid. Add the following code lines after the super():
Datasource_ds.selectedLines(true, Datasource, !selectedLines.exists(Datasource.RecId));
Datasource_ds.refresh();
Then when the user double clicks a method, it is selected.