Make dynamicly editable the grid based on a parameter

Hi Team, 

 

Somebody made this field dynamically? My case is based on the status you lock or unclock the editable grid list.

 

Like 1

Like

4 comments

I'd assume you could bind the property to an attribute and set as true false via code (but haven't confirmed or tried this). 

{
	"operation": "insert",
	"name": "MyListComponent",
	//...
	{
		"features": {
			"editable": "$IsMyListEditable"
		}
	}
}

Ryan

Ryan Farley,

I tried that and didn't work for me. Setting the attribute is been taked as "true" for the editable.

That's disappointing. I have experienced some issues with binding to nested properties like that one, so maybe the binding doesn't work there. I don't know of any other way to change that at runtime if it work work to bind an attribute there.

Hello,

The editability of the detail is controlled by the parameter "editable", for example:

{
                "operation": "merge",
                "name": "AddressList",
                "values": {
                    "features": {
                        "editable": true
                    },
                    "fitContent": true
                }
            },

However, In order to dynamically change it you need to bind a whole "features" object to an attribute.

Only after that, you can actually dynamically change the "editable" parameter by binding the "features" object to an attribute, here is an example:

viewConfigDiff: /**SCHEMA_VIEW_CONFIG_DIFF*/[
    {
        "operation": "insert",
        "name": "DataGrid_coc8r77",
        "values": {
            ...
            "features": "$DataGrid_coc8r77_Features",
        },
        "parentName": "Main",
        "propertyName": "items",
        "index": 2
    }
]
 
viewModelConfig: /**SCHEMA_VIEW_MODEL_CONFIG*/{
    "attributes": {
        "DataGrid_coc8r77": {
            ...
        },
        "DataGrid_coc8r77_Features": {
            "value": null
        }
    }
}

And then in the handler set the needed value to an "editable" attribute:

handlers: /**SCHEMA_HANDLERS*/[
    {
        request: "crt.ToggleListEditability",
        handler: async (request, next) => {
            const currentListFeatures = await request.$context.DataGrid_coc8r77_Features;
            const newListFeatures = {
                ...currentListFeatures,
                editable: !currentListFeatures?.editable,
            };
            request.$context.DataGrid_coc8r77_Features = newListFeatures;
            return next?.handle(request);
        }
    }
]

 

Thank you for reaching out!
 

Show all comments