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
2745
Column DataType Boolean - Change Combo Box Default Display Text
posted

I have a grid with two columns that contain boolean data types.  When trying to edit the grid the allowable values are "true" and "false".  Our client would like to see "Yes" and "No" respectively.  Is there a template I can override to display different text instead of the default?

Thanks,

  • 30
    Offline posted

    Display 'Yes' instead of 'true' for Boolean values igGrid combo using javascript

  • 2745
    Verified Answer
    Offline posted

    Here was my solution:

     

    Razor:

    feature.Updating()
        .ColumnSettings(setting =>
        {
            setting.ColumnSetting().ColumnKey("Id").Required(true).EditorType(ColumnEditorType.Combo).ComboEditorOptions(option =>
            {
                option.AllowCustomValue(false).DataSource(Model.NewComboValues).EnableClearButton(false).TextKey("Key").ValueKey("Value").ValueKeyType(ComboDataType.Bool);
            });
        });

    Model:

    public KeyValuePair<string, string>[] NewComboValues
    {
        get
        {
            return new KeyValuePair<string, string>[]
            {
                  new KeyValuePair<string, string>("Yes", Boolean.TrueString),
                  new KeyValuePair<string, string>("No", Boolean.FalseString)
            };
        }
    }

     

    Everything works perfectly!