I haven't found a post that describes my problem, so sorry in advanced if there is already one.
I have a simple grid that displays a couple of values. One of these values is a path to an icon. By using a template for that column, not the path but the icon itself is shown.
.Columns(c =>{ c.For(x => x.Id).HeaderText("ID").Width("5%").DataType("number"); c.For(x => x.Name).HeaderText("Company").Width("20%"); c.For(x => x.ShortName).HeaderText("Abbrivation").Width("10%"); c.For(x => x.DisplayIcon).HeaderText("Icon").Width("10%").Template("<img src='${DisplayIcon}' alt='icon' />");})
When in editmode, the field icon is a combo from where the user can select a different icon. The dropdown only shows the text, but I also want to use an image so they can see what the icon looks like. With a regular igCombo I can use an itemtemplate to add an <img /> element. But I haven't found out how to do this for an EditoCombo inside a grid.
this is the feature i've added
f.Updating().EnableAddRow(false).ColumnSettings(cs =>{ cs.ColumnSetting().ColumnKey("Id").ReadOnly(true); cs.ColumnSetting().ColumnKey("DisplayIcon").EditorType(ColumnEditorType.Combo).ComboEditorOptions(co => co.DataSource(ViewBag.SelectableIcons).ValueKey("ImageUrl").TextKey("Name").Mode(ComboMode.DropDown));});
Is this even possible?
Hello Sebastian,
To achieve this you need to use igCombo.itemTemplate, but this option is not available in the "ComboEditorOptions" method, that's why you need to use the generic "EditorOptions" method which accepts string and makes configuring a little bit difficult.
Here is how your column setting for the "DisplayIcon" should look like:
feature.Updating().ColumnSettings(cs => cs.ColumnSetting().ColumnKey("DisplayIcon").EditorType(ColumnEditorType.Combo).EditorOptions("valueKey: 'ImageUrl', textKey: 'Name', mode: 'dropdown', dataSource: " + Html.Raw(Json.Encode(ViewBag.SelectableIcons)) + ", itemTemplate: '<img src='${ImageUrl}' alt='icon' />'"));
Hope this helps,Martin PavlovInfragistics, Inc.
Did you have a chance to try my suggestion? Were you able to resolve your issue?
Best regards,Martin PavlovInfragistics, Inc.