Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
110
How to define default values for MVC igGrid
posted

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.

Parents
  • 20255
    Offline posted

    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.

Reply Children