Home > Ax Technical > Creating Edit methods for DS that don’t allow editing in Dynamics ax

Creating Edit methods for DS that don’t allow editing in Dynamics ax

December 30, 2010 Leave a comment Go to comments

Let’s say we have a Datasource and it is being displayed in the grid. The user has to choose one of it to further proceed. The use case is that you must be able to use a checkbox to select the records but you should not be able to modify rest of the information.

Technical implementation:
First Thought: Set allow create, allow delete allow edit property on the ds as false. Consequence: when you set allow edit as false you will no more be able to edit the checkbox also which is undesired.
Second Thought: Set allowedit false control wise either in the ds or in the formcontrol. Consequence: Too much work/customization. If done at formcontrol level the user can even add a field through
the syssteupform and start editing it (Refer here for details: http://wp.me/p298V-2IL)

Best Approach: Set allow edit to true in the ds 🙂 . Override the write method in the ds and comment the super. Consequence: Peaceful solution 😉

public void write()
{
    ;

    I4C_InventTrans_ds.reread();
    I4C_InventTrans_ds.refresh();
    //super();
}

[tweetmeme source=”casperkamal” http://www.url.com only_single=false]

  1. January 13, 2011 at 8:53 am

    I rather would loop trough all data source fields (FormDataObject) and set them allowEdit=false at initalization time of the form/ds. That’s more confortable for the user, because he sees, that he cannot modify other fields than the edit fields.

  1. No trackbacks yet.

Leave a comment