Hi,
Is it possible to set a title for a column in a DataGrid dynamically via client code?
I tried the following steps:
1. Add an attribute to viewModelConfigDiff called "InspectorsSundayCaption".
viewModelConfigDiff: /**SCHEMA_VIEW_MODEL_CONFIG_DIFF*/[
{
"operation": "merge",
"path": [
"attributes"
],
"values": {
"InspectorsSundayCaption":{
},
......}
2. Bind the attribute to the caption property of column
{
"id": "aaa335c2-8291-0f65-e930-e39ca7e333a7",
"code": "DataGrid_244wb6vDS_UsrwpPoliceCarsSunday",
"path": "UsrwpPoliceCarsSunday",
"caption":"$InspectorsSundayCaption2",
"dataValueType": 4
},
3. Set the attribute in the HandleViewModelInitRequest handler with the specific value.
{
request: "crt.HandleViewModelInitRequest",
handler: async (request, next) => {
.....
request.$context.InspectorsSundayCaption = "Sunday inspectors " + sundayDateStr;
await next?.handle(request);
}
This way work to me in normal column caption, But it doesn't work in a DataGrid column
Is there any limitation/step I'm missing?
Thanks in advance for your assistance!
Rachel
Like
Hello Rachel Markovski,
I have contacted our R&D team in order to help find a solution for your problem. The answer is unfortunate - currently there is no mechanism to dynamically change column caption in the datagrid component.
Hope this helps.