Hello,
I hope this is a simple question, can someone show me how to define default values for an MVC igGrid. Here's a snippet of my code:
.Features(feature => { feature.Updating().ColumnSettings(cs => { cs.ColumnSetting().ColumnKey("ActvtyKey").ReadOnly(true); cs.ColumnSetting().ColumnKey("ActvtyNm").Required(true).TextEditorOptions(o => o.ValidatorOptions(vo => vo.MinLength(2).KeepFocus(ValidatorKeepFocus.Never))); cs.ColumnSetting().ColumnKey("TrackngMetrcTxt").EditorType(ColumnEditorType.Text).Required(false); cs.ColumnSetting().ColumnKey("OngngStatsFlg").EditorType(ColumnEditorType.Combo).Required(false).ComboEditorOptions(co => co.DataSource(ViewBag.StatusText).ValueKey("FlagKey").TextKey("Status").Mode(ComboMode.DropDown)); }) .HorizontalMoveOnEnter(true) .ExcelNavigationMode(true) .EditMode(GridEditMode.Row); })
Can you please show how to set a default value for the text and combo editor please. Thank you.
Hello.
Thank you for contacting us.
About your question by saying default value you mean when the Grid initialize the editor to be already bind and to show values, right? You will need to set Value option in order to show some value by default like it is shown in the online sample below or to have a dataSource which the editor will use and when the value exists in the dataSource it will be automatically selected:
Code snippet:
{ columnKey: "Country", editorType: "combo", editorOptions: { dataSource: countries }},
...
http://igniteui.com/grid/editing-api-events
Let me know if I may be of further assistance.
No, that's not correct and not what I'm asking for. I have an MVC Grid with a comboeditor that is databound to a table lookup (this is very similar to the Basic Editor example):
cs.ColumnSetting().ColumnKey("OngngStatsFlg").EditorType(ColumnEditorType.Combo).Required(false).ComboEditorOptions(co => co.DataSource(ViewBag.StatusText).ValueKey("FlagKey").TextKey("Status").Mode(ComboMode.DropDown));
What I need is when the user clicks Add New Row, a default value is set. Being that this is bound to a lookup, the new row sets the comboeditor to null and if the user saves that row (this must be an optional field), the record breaks because there is no lookup for a null value.
So what I need is to set the default value for when the user adds a new row. I need an example for an MVC wrapper, not javascript as you pointed out above, for both a text box and combo editor. Thank you.