Пример #1
0
        private IEnumerable GetCustomPageSizeSet(Newegg.Oversea.Silverlight.Controls.Data.DataGrid dataGrid)
        {
            var set = new ObservableCollection <ComboBoxItem>();

            foreach (var item in dataGrid.PageSizeSet)
            {
                set.Add(new ComboBoxItem {
                    Content = item.DisplayName, Tag = item.PageSize
                });
            }

            return(set);
        }
Пример #2
0
        /// <summary>
        /// 初始化每页显示数量集合
        /// </summary>
        /// <param name="cmbpageSizeSet"></param>
        /// <param name="dataGrid"></param>
        public void InitPageSizeSet(ref ComboBox cmbpageSizeSet, Newegg.Oversea.Silverlight.Controls.Data.DataGrid dataGrid)
        {
            cmbpageSizeSet.ItemsSource = dataGrid.PageSizeSet == null?GetDefaultPageSizeSet() : GetCustomPageSizeSet(dataGrid);

            if (dataGrid.PageSizeSet != null && dataGrid.PageSizeSet.Count > 0)
            {
                var b = dataGrid.PageSizeSet.Any(item => item.IsDefault == true);

                Queue <int> queue = new Queue <int>();

                foreach (var i in dataGrid.PageSizeSet)
                {
                    if (!b)
                    {
                        queue.Enqueue(i.PageSize);
                    }
                    else if (b && i.IsDefault)
                    {
                        queue.Enqueue(i.PageSize);
                    }
                }

                var minValue = queue.Dequeue();

                while (queue.Count > 0)
                {
                    var i = queue.Dequeue();

                    if (i < minValue)
                    {
                        minValue = i;
                    }
                }

                m_resetGridConfig.PageSize          = minValue;
                dataGrid.m_resetGridConfig.PageSize = minValue;
                dataGrid.PageSize = minValue;
            }


            foreach (var item in cmbpageSizeSet.Items)
            {
                var comboBoxItem = item as ComboBoxItem;

                if (dataGrid != null)
                {
                    if (!dataGrid.IsShowPager)
                    {
                        if (comboBoxItem.Tag.ToString() == "10000")
                        {
                            cmbpageSizeSet.SelectedItem = comboBoxItem;
                            cmbpageSizeSet.IsEnabled    = false;
                            break;
                        }
                    }
                    else
                    {
                        if (int.Parse(comboBoxItem.Tag.ToString()) == dataGrid.PageSize)
                        {
                            cmbpageSizeSet.SelectedItem = comboBoxItem;
                            break;
                        }
                    }
                }
            }

            if (cmbpageSizeSet.SelectedItem == null)
            {
                cmbpageSizeSet.SelectedIndex = 0;
            }
        }