protected void grid_AutoFilterCellEditorCreate(object sender, ASPxGridViewEditorCreateEventArgs e)
    {
        if (!IsCustomColumnFiltering(e.Column))
        {
            return;
        }
        ComboBoxProperties combo = new ComboBoxProperties();

        combo.Items.Add("Show All", ShowAllFilterId);
        if (Equals(e.Column, grid.Columns["Quantity"]))
        {
            for (int i = 0; i < 130 / IntStep; i++)
            {
                combo.Items.Add(string.Format("From {0} to {1}", i * IntStep, (i + 1) * IntStep - 1), i);
            }
        }
        if (Equals(e.Column, grid.Columns["UnitPrice"]))
        {
            for (int i = 0; i < 300 / DecimalStep; i++)
            {
                combo.Items.Add(string.Format("Less than {0:c}", (i + 1) * DecimalStep), i);
            }
        }
        if (Equals(e.Column, grid.Columns["CompanyName"]))
        {
            for (int i = 0; i <= 26 / SymbolStep; i++)
            {
                char[] values = GetSymbolValue(i);
                combo.Items.Add(string.Format("From {0} to {1}", values[0], values[1]), i);
            }
        }
        e.EditorProperties = combo;
    }
Exemplo n.º 2
0
    protected void ASPxGridView1_AutoFilterCellEditorCreate(object sender, DevExpress.Web.ASPxGridViewEditorCreateEventArgs e)
    {
        if (e.Column.FieldName != "Month")
        {
            return;
        }
        ComboBoxProperties comboBoxProp = new ComboBoxProperties();

        e.EditorProperties = comboBoxProp;
    }
Exemplo n.º 3
0
    protected void grid_AutoFilterCellEditorCreate(object sender, ASPxGridViewEditorCreateEventArgs e)
    {
        if (e.Column.FieldName != "Value")
        {
            return;
        }

        ComboBoxProperties combo = new ComboBoxProperties();

        combo.EnableCallbackMode       = true;
        combo.CallbackPageSize         = 10;
        combo.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
        e.EditorProperties             = combo;
    }
Exemplo n.º 4
0
        private ComboBox BuildComboBox(object data, BuildContext bc)
        {
            ComboBoxProperties properties =
                DataNodeWrapper.GetNodeAttributes(data).To <ComboBoxProperties>();

            JSObject[] children = DataNodeWrapper.GetNodeChildren(data);

            Menu menu = null;

            MenuLauncherControlProperties launcherProperties =
                DataNodeWrapper.GetNodeAttributes(data).To <MenuLauncherControlProperties>();

            Dictionary <string, string> menuItems = null;

            if (!Utility.IsTrue(launcherProperties.PopulateDynamically))
            {
                // Since PopulateDynamically is not true, we pass in "false" for LazyInit
                menu = BuildMenu(children[0], bc, false);

                // Parse XML subtree to build MenuItem list for auto-complete
                menuItems = new Dictionary <string, string>();
                JSObject[] sections = DataNodeWrapper.GetNodeChildren(children[0]);
                int        l        = sections.Length;
                for (int i = 0; i < l; i++)
                {
                    // Get children of the MenuSection node
                    JSObject[] sectionChildren = DataNodeWrapper.GetNodeChildren(sections[i]);
                    // Get children of the Controls node within the MenuSection
                    // There should only be 1 Controls node within the MenuSection subtree
                    JSObject[] items = DataNodeWrapper.GetNodeChildren(sectionChildren[0]);
                    int        m     = items.Length;
                    for (int j = 0; j < m; j++)
                    {
                        string labeltext  = DataNodeWrapper.GetAttribute(items[j], DataNodeWrapper.LABELTEXT);
                        string menuitemid = DataNodeWrapper.GetAttribute(items[j], DataNodeWrapper.MENUITEMID);
                        menuItems[labeltext] = menuitemid;
                    }
                }
            }

            ComboBox fscb = new ComboBox(Root,
                                         properties.Id,
                                         properties,
                                         menu);

            fscb.MenuItems = menuItems;
            return(fscb);
        }
    EditPropertiesBase CreateComboBoxProperties(object value)
    {
        bool v     = value != null && (bool)value;
        var  props = new ComboBoxProperties();

        props.ValueType = typeof(bool);
        props.Items.Add(new ListEditItem("Need alert", true)
        {
            Selected = v
        });
        props.Items.Add(new ListEditItem("Is's ok", false)
        {
            Selected = !v
        });
        return(props);
    }
    protected void grid_AutoFilterCellEditorCreate(object sender, ASPxGridViewEditorCreateEventArgs e)
    {
        ASPxGridView grid = sender as ASPxGridView;

        if (e.Column.FieldName != "CategoryName")
        {
            return;
        }
        ComboBoxProperties combo   = new ComboBoxProperties();
        string             command = string.Format("SELECT DISTINCT [{0}] FROM [CategoriesFilter]", e.Column.FieldName);
        AccessDataSource   ds      = new AccessDataSource(AccessDataSource1.DataFile, command);
        DataView           dv      = ds.Select(DataSourceSelectArguments.Empty) as DataView;

        combo.Items.Add(ShowAllFilterId);
        for (int i = 0; i < dv.Count; i++)
        {
            combo.Items.Add(dv[i][0].ToString());
        }
        e.EditorProperties = combo;
    }
Exemplo n.º 7
0
        private void ComponentsCombo_LostFocus(object sender, RoutedEventArgs e)
        {
            ComboBoxProperties comboboxproperties = new ComboBoxProperties();

            for (int i = 0; i < comboboxproperties.Products.Count; i++)
            {
                if (ProductsCombo.SelectedItem == null)
                {
                    ComponentsCombo.IsEnabled = false;
                }
                else
                {
                    if (comboboxproperties.Products[i] == ProductsCombo.SelectedItem)
                    {
                        ComponentsCombo.IsEnabled = false;
                    }
                    else
                    {
                        ComponentsCombo.IsEnabled = true;
                    }
                }
            }
        }
Exemplo n.º 8
0
        public static ComboBoxProperties InitColumnLookupEdit(ComboBoxProperties cboProperty, STGridColumnsInfo objGridColumnInfo)
        {
            string sTGridColumnRepository = objGridColumnInfo.STGridColumnRepository;

            if (string.IsNullOrEmpty(sTGridColumnRepository))
            {
                //GMCDbUtil.GetPrimaryTableWhichForeignColumnReferenceTo(objGridColumnInfo.STGridColumnTableName, objGridColumnInfo.STGridColumnName);
            }
            string lookupQueryColumn = GetLookupQueryColumn(objGridColumnInfo);

            TryToInitLookupTable(sTGridColumnRepository, lookupQueryColumn);
            if (!GMCWebApp.LookupTables.ContainsKey(sTGridColumnRepository))
            {
                return(null);
            }
            DataView dvLookupTable       = new DataView();
            string   strPrimaryRepostory = GMCDbUtil.GetTablePrimaryColumn(sTGridColumnRepository);

            if (GMCDbUtil.IsForeignKey(sTGridColumnRepository, objGridColumnInfo.STGridColumnRepoDsplMem))
            {
                string primaryTableWhichForeignColumnReferenceTo = GMCDbUtil.GetPrimaryTableWhichForeignColumnReferenceTo(sTGridColumnRepository, objGridColumnInfo.STGridColumnRepoDsplMem);
                if (!string.IsNullOrEmpty(primaryTableWhichForeignColumnReferenceTo))
                {
                    string str7 = GMCWebApp.GetLookupQueryColumn(primaryTableWhichForeignColumnReferenceTo);
                    if (string.IsNullOrEmpty(str7))
                    {
                        str7 = "*";
                    }
                    else
                    {
                        str7 = str7.Replace(",", ",b.");
                    }
                    string  strQuery = string.Format("SELECT a.{0},b.{5}\r\n                        FROM {1} a\r\n                        INNER JOIN {2} b ON a.{3} = b.{4}", new object[] { strPrimaryRepostory, sTGridColumnRepository, primaryTableWhichForeignColumnReferenceTo, objGridColumnInfo.STGridColumnRepoDsplMem, GMCDbUtil.GetTablePrimaryColumn(primaryTableWhichForeignColumnReferenceTo), str7 });
                    DataSet dataSet  = BusinessControllerFactory.GetBusinessController(sTGridColumnRepository + "Controller").GetDataSet(strQuery);
                    if ((dataSet != null) && (dataSet.Tables.Count > 0))
                    {
                        string strLookupTableName = sTGridColumnRepository + "_" + primaryTableWhichForeignColumnReferenceTo;
                        dvLookupTable = dataSet.Tables[0].DefaultView;
                        if (!GMCWebApp.LookupTables.ContainsKey(strLookupTableName))
                        {
                            GMCWebApp.LookupTables.Add(strLookupTableName, dataSet.Tables[0]);
                        }
                        else
                        {
                            GMCWebApp.LookupTables[strLookupTableName] = dataSet.Tables[0];
                        }
                    }
                }
            }
            else
            {
                dvLookupTable = GMCWebApp.LookupTables[sTGridColumnRepository].DefaultView;
            }
            string sTGridColumnRepoDsplMem = objGridColumnInfo.STGridColumnRepoDsplMem;

            if (!dvLookupTable.Table.Columns.Contains(sTGridColumnRepoDsplMem))
            {
                sTGridColumnRepoDsplMem = "";
            }
            if (string.IsNullOrEmpty(sTGridColumnRepoDsplMem))
            {
                sTGridColumnRepoDsplMem = strPrimaryRepostory.Substring(0, strPrimaryRepostory.Length - 2) + "No";
            }
            if (GMCDbUtil.IsForeignKey(sTGridColumnRepository, objGridColumnInfo.STGridColumnRepoDsplMem))
            {
                string str13 = GMCDbUtil.GetPrimaryTableWhichForeignColumnReferenceTo(sTGridColumnRepository, objGridColumnInfo.STGridColumnRepoDsplMem);
                if (string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoCol1))
                {
                    sTGridColumnRepoDsplMem = str13.Substring(0, str13.Length - 1) + "No";
                }
                else
                {
                    sTGridColumnRepoDsplMem = objGridColumnInfo.STGridColumnRepoCol1;
                }
            }
            if (cboProperty == null)
            {
                cboProperty = new ComboBoxProperties();
            }
            DataTable dtLookupTable = dvLookupTable.ToTable(false, strPrimaryRepostory, sTGridColumnRepoDsplMem);

            cboProperty.DataSource    = dtLookupTable.DefaultView;
            cboProperty.TextField     = sTGridColumnRepoDsplMem;
            cboProperty.ValueField    = strPrimaryRepostory;
            cboProperty.ValueType     = GMCDbUtil.GetCSharpVariableType(objGridColumnInfo.STGridColumnTableName, objGridColumnInfo.STGridColumnName);
            cboProperty.DropDownStyle = DropDownStyle.DropDownList;
            if (string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoCol1))
            {
                ListBoxColumn column = new ListBoxColumn(sTGridColumnRepoDsplMem);
                if (sTGridColumnRepoDsplMem.EndsWith("No"))
                {
                    column.Caption = "Mã số";
                    column.Width   = 50;
                }
                else if (sTGridColumnRepoDsplMem.EndsWith("Name"))
                {
                    column.Caption = "Tên";
                    column.Width   = 200;
                }
                cboProperty.Columns.AddColumn(dtLookupTable, column);
                if (!GMCDbUtil.IsForeignKey(sTGridColumnRepository, objGridColumnInfo.STGridColumnRepoDsplMem))
                {
                    ListBoxColumn column1 = new ListBoxColumn();
                    if (sTGridColumnRepoDsplMem.EndsWith("No"))
                    {
                        column1.FieldName = sTGridColumnRepoDsplMem.Substring(0, sTGridColumnRepoDsplMem.Length - 2) + "Name";
                        column1.Caption   = GMCWebApp.GetControlText("Tên");
                        column1.Width     = 200;
                    }
                    else if (sTGridColumnRepoDsplMem.EndsWith("Name"))
                    {
                        column1.FieldName = sTGridColumnRepoDsplMem.Substring(0, sTGridColumnRepoDsplMem.Length - 4) + "No";
                        column1.Caption   = GMCWebApp.GetControlText("Mã số");
                        column1.Width     = 50;
                    }
                    cboProperty.Columns.AddColumn(dtLookupTable, column1);
                }
            }
            else
            {
                ListBoxColumn info6 = new ListBoxColumn
                {
                    FieldName = objGridColumnInfo.STGridColumnRepoCol1,
                    Caption   = GMCWebApp.GetControlText(objGridColumnInfo.STGridColumnRepoCol1Caption),
                    Width     = 100
                };
                cboProperty.Columns.AddColumn(dtLookupTable, info6);
                if (!string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoCol2))
                {
                    ListBoxColumn info7 = new ListBoxColumn
                    {
                        FieldName = objGridColumnInfo.STGridColumnRepoCol2,
                        Caption   = GMCWebApp.GetControlText(objGridColumnInfo.STGridColumnRepoCol2Caption),
                        Width     = 100,
                    };
                    cboProperty.Columns.AddColumn(dtLookupTable, info7);
                }
                if (!string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoCol3))
                {
                    ListBoxColumn info8 = new ListBoxColumn
                    {
                        FieldName = objGridColumnInfo.STGridColumnRepoCol3,
                        Caption   = GMCWebApp.GetControlText(objGridColumnInfo.STGridColumnRepoCol3Caption),
                        Width     = 100
                    };
                    cboProperty.Columns.AddColumn(dtLookupTable, info8);
                }
                if (!string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoCol4))
                {
                    ListBoxColumn info9 = new ListBoxColumn
                    {
                        FieldName = objGridColumnInfo.STGridColumnRepoCol4,
                        Caption   = GMCWebApp.GetControlText(objGridColumnInfo.STGridColumnRepoCol4Caption),
                        Width     = 100
                    };
                    cboProperty.Columns.AddColumn(dtLookupTable, info9);
                }
                if (!string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoCol5))
                {
                    ListBoxColumn info10 = new ListBoxColumn
                    {
                        FieldName = objGridColumnInfo.STGridColumnRepoCol5,
                        Caption   = GMCWebApp.GetControlText(objGridColumnInfo.STGridColumnRepoCol5Caption),
                        Width     = 100
                    };
                    cboProperty.Columns.AddColumn(dtLookupTable, info10);
                }
            }
            if (!string.IsNullOrEmpty(objGridColumnInfo.STGridColumnRepoDsplMem))
            {
                int idx = cboProperty.Columns.Cast <ListBoxColumn>().ToList().FindIndex(x => x.FieldName.Equals(objGridColumnInfo.STGridColumnRepoDsplMem));
                if (idx != -1)
                {
                    cboProperty.TextFormatString = "{" + idx.ToString() + "}";
                }
            }
            return(cboProperty);
        }
Exemplo n.º 9
0
 public static void BindComboBoxToEnum(ComboBoxProperties prop, Type enumType)
 {
     prop.ValueType = enumType;
     PopulateComboBoxItems(prop.Items, enumType);
 }