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
195
equivalent property of valuelist in the new version of webdatagrid
posted

Hi, I upgraded to Infragistics 14.2 and I am trying to initialize a column as a dropdown whose value is coming from a data table. What is the equivalent property of valuelist in the new version of webdatagrid GridField  column?Please help to convert the below code .

After I upgraded I changed the UltraGridColum to GridField. Please help . Thank you!

public void InitCreCAPTCHA challenge imageolumnDropDown(UltraGridColumn col, DataTable dt, string valueColumn, string displayColumn,

object emptyValue, string emptyDisplayValue)

{

if (col == null) throw new ArgumentNullException();

if (dt == null || dt.Columns.Count <= 0) throw new ArgumentNullException();

if (valueColumn == null || valueColumn.Trim().Length <= 0 ||

displayColumn == null || displayColumn.Trim().Length <= 0)

throw new ArgumentNullException();

col.ValueList.Reset();

if (emptyValue != null && emptyDisplayValue != null)

col.ValueList.ValueListItems.Add(emptyValue, emptyDisplayValue);

int id = dt.Columns.IndexOf(valueColumn);

int name = dt.Columns.IndexOf(displayColumn);

foreach (DataRow dr in dt.Rows)

{

col.ValueList.ValueListItems.Add(dr[id], dr[name].ToString());

}

col.ValueList.Style.Font.Name = "Microsoft Sans Serif";

col.ValueList.Style.Font.Size = FontUnit.XXSmall;

col.Type = ColumnType.DropDownList;

}

Parents
  • 2680
    Offline posted

    Hello,

    Thank you for contacting us.

    In order to achieve the same behaviour with WebDataGrid, you should use DropDownProvider for EditorProvider of the specified colum (sample - http://www.infragistics.com/samples/aspnet/data-grid/dropdown-editors). In this case the desired function would look like this:

    public void InitColumnDropDown(WebDropDown dd, DataTable dt, string valueColumn, string displayColumn,
        object emptyValue, string emptyDisplayValue)
    {

        if (dd == null) throw new ArgumentNullException();
        if (dt == null || dt.Columns.Count <= 0) throw new ArgumentNullException();
        if (valueColumn == null || valueColumn.Trim().Length <= 0 ||
         displayColumn == null || displayColumn.Trim().Length <= 0)
            throw new ArgumentNullException();

        if (emptyValue != null && emptyDisplayValue != null)
        {
            DataRow emptyRow = dt.NewRow();
            emptyRow[valueColumn] = emptyValue;
            emptyRow[displayColumn] = emptyDisplayValue;
            dt.Rows.InsertAt(emptyRow, 0);
        }

        dd.DataSource = dt;
        dd.ValueField = valueColumn;
        dd.TextField = displayColumn;
        dd.ValueDisplayType = DropDownValueDisplayType.Simple;
        dd.Font.Name = "Microsoft Sans Serif";
        dd.Font.Size = FontUnit.XXSmall;
    }

    I am attaching a working sample of the described scenario.

    Looking forward to hearing from you.

    DropDownColumn.zip
Reply Children