I'm writing a Widget plugin which trying to add one more column as the first column of Category datatable, in Category/List page, just like Product/List page, the first checkbox column.
I searched a lot, seems one easy solution is subscribe to ModelPreparedEvent and then write my own logic to add a new 'ColumnProperty'. I wrote a event handler but it's not working. I'm using Nop4.2. Thanks.
Here is my handleEvent code:
public void HandleEvent(ModelPreparedEvent<DataTablesModel> eventMessage)
{
if (eventMessage.Model.Name == "categories-grid")
{
eventMessage.Model.ColumnCollection.Insert(1, new ColumnProperty("Checkbox")
{
IsMasterCheckBox = true,
Render = new RenderCheckBox("checkbox_categories"),
ClassName = NopColumnClassDefaults.CenterAll,
Width = "50"
});
}
}