I'm using the great NonFactor MVC Grid with quite a bit of success, but I am seeing a weird issue:
@(Html
.Grid(items)
.Build(columns =>
{
columns.Add(model => model.Type).Formatted("{0}" == "folder" ? "<span class=\"glyphicon glyphicon-folder-open\"></span>" : "<span class=\"glyphicon glyphicon-file\"></span>").Encoded(false);
columns.Add(model => model.Id).Titled("Id");
columns.Add(model => model.Name).Titled("Name");
columns.Add(model => model.Size).Titled("Size");
})
.Empty("No data found")
.Sortable()
)
Here, if the row's property Type
is equal to folder
, its should display the folder icon in that column. However I'm finding that the 2nd option is always used for that Formatted
column.
so if I switch the options around for that ternary operator, then the folder icon is always displayed, where currently the file icon is always displayed.
Does anyone know why that is happening, and if there is a way of overcoming this?
I ended up just doing this instead
So the line
Will show a folder icon if its a folder, and nothing if its a file (since
glyphicon-file-open
is not a valid icon class)Not the best solution as there is not icon for files now, but its good enough.