Beispiel #1
0
    /// <summary>
    /// Configures the grids displaying objects
    /// </summary>
    private void SetupUniGrids()
    {
        var pagerConfig = new UniGridPagerConfig()
        {
            DefaultPageSize = -1,
            DisplayPager    = false,
        };

        gridFiles.OnDataReload += gridFiles_OnDataReload;
        gridFiles.PagerConfig   = pagerConfig;

        gridObjects.OnDataReload += gridObjects_OnDataReload;
        gridObjects.PagerConfig   = pagerConfig;
    }
Beispiel #2
0
    /// <summary>
    /// Load unigrid pager configuration.
    /// </summary>
    /// <param name="config">Pager configuration</param>
    private void LoadPagerDefinition(UniGridPagerConfig config)
    {
        if (config.DisplayPager != null)
        {
            Pager.DisplayPager = config.DisplayPager.Value;
        }

        // Load definition only if pager is displayed
        if (Pager.DisplayPager)
        {
            if (config.PageSizeOptions != null)
            {
                Pager.PageSizeOptions = config.PageSizeOptions;
            }
            if (config.ShowDirectPageControl != null)
            {
                Pager.ShowDirectPageControl = config.ShowDirectPageControl.Value;
            }
            if (config.ShowFirstLastButtons != null)
            {
                Pager.ShowFirstLastButtons = config.ShowFirstLastButtons.Value;
            }
            if (config.ShowPageSize != null)
            {
                Pager.ShowPageSize = config.ShowPageSize.Value;
            }
            if (config.ShowPreviousNextButtons != null)
            {
                Pager.ShowPreviousNextButtons = config.ShowPreviousNextButtons.Value;
            }
            if (config.ShowPreviousNextPageGroup != null)
            {
                Pager.ShowPreviousNextPageGroup = config.ShowPreviousNextPageGroup.Value;
            }
            if (config.VisiblePages > 0)
            {
                Pager.VisiblePages = config.VisiblePages;
                visiblePagesSet = true;
            }
            if (config.DefaultPageSize > 0)
            {
                Pager.DefaultPageSize = config.DefaultPageSize;
            }

            // Try to get page size from request
            string selectedPageSize = Request.Form[Pager.PageSizeDropdown.UniqueID];
            int pageSize = 0;

            if (selectedPageSize != null)
            {
                pageSize = ValidationHelper.GetInteger(selectedPageSize, 0);
            }
            else if (config.DefaultPageSize > 0)
            {
                pageSize = config.DefaultPageSize;
            }

            if ((pageSize > 0) || (pageSize == -1))
            {
                Pager.CurrentPageSize = pageSize;
            }
        }
        else
        {
            // Reset page size
            Pager.CurrentPageSize = -1;
        }
    }
Beispiel #3
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>
    /// Configures the grids displaying objects
    /// </summary>
    private void SetupUniGrids()
    {
        var pagerConfig = new UniGridPagerConfig()
        {
            DefaultPageSize = -1,
            DisplayPager = false,
        };

        gridFiles.OnDataReload += gridFiles_OnDataReload;
        gridFiles.PagerConfig = pagerConfig;

        gridObjects.OnDataReload += gridObjects_OnDataReload;
        gridObjects.PagerConfig = pagerConfig;
    }