Пример #1
0
    /// <summary>
    /// Load options definition.
    /// </summary>
    /// <param name="options">Options configuration</param>
    /// <param name="filterTable">Table for filter</param>
    private void LoadOptionsDefinition(UniGridOptions options, Table filterTable)
    {
        // Create filter table according to the key value "DisplayFilter"
        displayFilter = options.DisplayFilter;
        if (displayFilter)
        {
            filter.Controls.Add(filterTable);
        }

        // Filter limit
        if (options.FilterLimit > -1)
        {
            FilterLimit = options.FilterLimit;
        }

        // Display sort direction images
        showSortDirection = options.ShowSortDirection;

        // Display selection column with checkboxes
        showSelection = options.ShowSelection;
        if (showSelection)
        {
            TemplateField chkColumn = new TemplateField();

            using (CheckBox headerBox = new CheckBox { ID = "headerBox" })
            {
                using (CheckBox itemBox = new CheckBox { ID = "itemBox" })
                {
                    // Set selection argument
                    itemBox.Attributes["selectioncolumn"] = options.SelectionColumn;
                    chkColumn.HeaderTemplate = new GridViewTemplate(ListItemType.Header, this, headerBox);
                    chkColumn.ItemTemplate = new GridViewTemplate(ListItemType.Item, this, itemBox);
                }
            }
            UniGridView.Columns.Add(chkColumn);
        }

        // Get pagesize options
        if (!String.IsNullOrEmpty(options.PageSize))
        {
            Pager.PageSizeOptions = options.PageSize;
        }

        // Set pagging acording to the key value "DisplayPageSizeDropdown"
        if (options.DisplayPageSizeDropdown != null)
        {
            Pager.ShowPageSize = options.DisplayPageSizeDropdown.Value;
        }
    }
Пример #2
0
    /// <summary>
    /// Loads the XML configuration of the grid.
    /// </summary>
    public bool LoadXmlConfiguration()
    {
        // If no configuration is given, do not process
        if (string.IsNullOrEmpty(GridName))
        {
            return true;
        }
        string xmlFilePath = Server.MapPath(GridName);

        // Check the configuration file
        if (!File.Exists(xmlFilePath))
        {
            lblError.Text = String.Format(GetString("unigrid.noxmlfile"), xmlFilePath);
            lblError.Visible = true;
            return false;
        }

        // Load the XML configuration
        XmlDocument document = new XmlDocument();
        document.Load(xmlFilePath);
        XmlNode node = document.DocumentElement;

        if (node != null)
        {
            // Load options definition
            XmlNode optionNode = node.SelectSingleNode("options");
            if (optionNode != null)
            {
                GridOptions = new UniGridOptions(optionNode);
            }

            // Load actions definition
            XmlNode actionsNode = node.SelectSingleNode("actions");
            if (actionsNode != null)
            {
                GridActions = new UniGridActions(actionsNode);
            }

            // Load pager definition
            XmlNode pagerNode = node.SelectSingleNode("pager");
            if (pagerNode != null)
            {
                PagerConfig = new UniGridPagerConfig(pagerNode);
            }

            // Select list of "column" nodes
            XmlNode columnsNode = node.SelectSingleNode("columns");
            if (columnsNode != null)
            {
                GridColumns = new UniGridColumns(columnsNode);
            }

            // Try to get ObjectType from definition
            XmlNode objectTypeNode = node.SelectSingleNode("objecttype");
            if (objectTypeNode != null)
            {
                // Get object type information
                LoadObjectTypeDefinition(objectTypeNode);
            }
            else
            {
                // Get query information
                XmlNode queryNode = node.SelectSingleNode("query");
                LoadQueryDefinition(queryNode);
            }

            return true;
        }

        return false;
    }
    /// <summary>
    /// Load options definition.
    /// </summary>
    /// <param name="options">Options configuration</param>
    /// <param name="filterWrapperControl">Wrapper control for filter</param>
    private void LoadOptionsDefinition(UniGridOptions options, Control filterWrapperControl)
    {
        // Add custom filter or filter wrapper panel according to the key value "DisplayFilter"
        displayFilter = options.DisplayFilter;

        if (displayFilter)
        {
            // Add custom filter
            if (!mCustomFilterAdded && !string.IsNullOrEmpty(options.FilterPath))
            {
                UniGridFilterField filterDefinition = new UniGridFilterField();
                CMSAbstractBaseFilterControl filterControl = LoadFilterControl(options.FilterPath, CUSTOM_FILTER_SOURCE_NAME, null, filterDefinition);
                FilterFields[CUSTOM_FILTER_SOURCE_NAME] = filterDefinition;
                mCustomFilterAdded = true;

                plcFilter.Controls.Add(filterControl);

                RaiseOnFilterFieldCreated(null, filterDefinition);
            }
            // Add wrapper panel for default filter
            else
            {
                plcFilter.Controls.Add(filterWrapperControl);
            }
        }

        // Filter limit
        if (options.FilterLimit > -1)
        {
            FilterLimit = options.FilterLimit;
        }

        // Display sort direction images
        showSortDirection = options.ShowSortDirection;

        // Display selection column with checkboxes
        showSelection = options.ShowSelection;
        if (showSelection)
        {
            TemplateField chkColumn = new TemplateField();

            using (CMSCheckBox headerBox = new CMSCheckBox
            {
                ID = "headerBox"
            })
            {
                using (CMSCheckBox itemBox = new CMSCheckBox
                {
                    ID = "itemBox"
                })
                {
                    // Set selection argument
                    itemBox.Attributes["selectioncolumn"] = options.SelectionColumn;
                    chkColumn.HeaderTemplate = new GridViewTemplate(ListItemType.Header, this, headerBox);
                    chkColumn.ItemTemplate = new GridViewTemplate(ListItemType.Item, this, itemBox);
                }
            }
            GridView.Columns.Add(chkColumn);
        }

        // PageSize and DisplayPageSizeDropdown properties are obsolete.
        // This code ensures backward compatibility.
        // #pragma statement disables warnings for using obsolete attribute.
        #pragma warning disable 612, 618
        if (!String.IsNullOrEmpty(options.PageSize))
        {
            Pager.PageSizeOptions = options.PageSize;
        }

        // Set paging according to the key value "DisplayPageSizeDropdown"
        if (options.DisplayPageSizeDropdown != null)
        {
            Pager.ShowPageSize = options.DisplayPageSizeDropdown.Value;
        }
        #pragma warning restore 612, 618
    }