I want to give if condition between datatable ColumnProperty. I tried but throwing syntax error. And from that I confused that how can I set if condition between ColumnProperty of datatable.
Here is my code,
@await Html.PartialAsync("Table", new DataTablesModel
{
Name = "collection-grid",
UrlRead = new DataUrl("CollectionList", "Customer",
new RouteValueDictionary { [nameof(Model.CustomerCollectionSearchModel.CustomerID)] = Model.Id }),
UrlDelete = new DataUrl("CollectionDelete", "Customer", null),
Length = Model.CustomerCollectionSearchModel.PageSize,
LengthMenu = Model.CustomerCollectionSearchModel.AvailablePageSizes,
ColumnCollection = new List<ColumnProperty>
{
new ColumnProperty(nameof(CustomerCollectionModel.CollectionName))
{
Title = T("Admin.Customer.Collection.Fields.CollectionName").Text,
Width = "200"
},
if(Model.CustomerRoleNames == "Admin")
{
new ColumnProperty(nameof(CustomerCollectionModel.Id))
{
Title = T("Admin.Common.Delete").Text,
Width = "100",
Render = new RenderButtonRemove(T("Admin.Common.Delete").Text),
ClassName = NopColumnClassDefaults.Button
}
}
}
})
Latest I used if condition in datatable but it showing red line error.
Is there any way to used if condition in datatable ColumnProperty?
Aucun commentaire:
Enregistrer un commentaire