Пример #1
0
        public async Task SetChecked(bool value)
        {
            if (Column.HeaderCheckbox)
            {
                // set a value and init ExceptCheckedRows for this column
                _allChecked     = value;
                _showAllChecked = true;
                GridComponent.ExceptCheckedRows.AddParameter(Column.Name, new QueryDictionary <bool>());

                CheckboxEventArgs <T> args = new CheckboxEventArgs <T>
                {
                    ColumnName = Column.Name
                };
                if (value)
                {
                    args.Value = CheckboxValue.Checked;
                }
                else
                {
                    args.Value = CheckboxValue.Unchecked;
                }
                await GridComponent.OnHeaderCheckboxChanged(args);

                StateHasChanged();
            }
        }
Пример #2
0
        private async Task RowCheckboxChanged(CheckboxEventArgs <T> e)
        {
            if (e.ColumnName != Column.Name || !Column.HeaderCheckbox)
            {
                return;
            }
            var oldValue = _allChecked;

            var checkedCount = GridComponent.CheckboxesKeyed.Get(Column.Name).Values.Count(r => r.Item2);

            if (checkedCount > 0 && checkedCount != GridComponent.Grid.Pager.OriginalItemsCount)
            {
                _allChecked = null;
            }
            else
            {
                _allChecked            = checkedCount == GridComponent.Grid.Pager.OriginalItemsCount;
                LastHeaderCheckedValue = _allChecked == true;
                GridComponent.CheckboxesKeyed.AddParameter(Column.Name, new QueryDictionary <(CheckboxComponent <T>, bool)>());
            }

            if (_allChecked != oldValue)
            {
                var args = new HeaderCheckboxEventArgs <T>
                {
                    ColumnName  = Column.Name,
                    Value       = _allChecked == true ? CheckboxValue.Checked : CheckboxValue.Unchecked,
                    HeaderValue = _allChecked == null ? CheckboxValue.Gray : (_allChecked == true ? CheckboxValue.Checked : CheckboxValue.Unchecked),
                    StringKey   = e.StringKey,
                };
                await GridComponent.OnHeaderCheckboxChanged(args);
                await InvokeAsync(StateHasChanged);
            }
        }
Пример #3
0
        public async Task SetChecked(bool value)
        {
            if (!Column.HeaderCheckbox)
            {
                return;
            }
            var oldValue = _allChecked;

            _allChecked = value;
            var allItemsDisplayed = GridComponent.Grid.ItemsCount == GridComponent.Grid.OriginalItemsCount;

            if (allItemsDisplayed)
            {
                GridComponent.CheckboxesKeyed.AddParameter(Column.Name, new QueryDictionary <(CheckboxComponent <T>, bool)>());
                LastHeaderCheckedValue = value;
            }

            var args = new HeaderCheckboxEventArgs <T>
            {
                ColumnName  = Column.Name,
                Value       = value ? CheckboxValue.Checked : CheckboxValue.Unchecked,
                HeaderValue = value ? CheckboxValue.Checked : CheckboxValue.Unchecked,
            };

            if (_allChecked != oldValue)
            {
                await GridComponent.OnHeaderCheckboxChanged(args);
                await InvokeAsync(StateHasChanged);
            }
        }
Пример #4
0
        public async Task SetChecked(bool value)
        {
            if (Column.HeaderCheckbox)
            {
                _allChecked = value;
                CheckboxEventArgs <T> args = new CheckboxEventArgs <T>
                {
                    ColumnName = Column.Name
                };
                if (_allChecked)
                {
                    args.Value = CheckboxValue.Checked;
                }
                else
                {
                    args.Value = CheckboxValue.Unchecked;
                }
                await GridComponent.OnHeaderCheckboxChanged(args);

                StateHasChanged();
            }
        }