Beispiel #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();
            }
        }
 internal virtual async Task OnRowCheckboxChanged(CheckboxEventArgs <T> args)
 {
     if (RowCheckboxChanged != null)
     {
         await RowCheckboxChanged.Invoke(args);
     }
 }
Beispiel #3
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);
            }
        }
Beispiel #4
0
 private async Task RowCheckboxChanged(CheckboxEventArgs <T> e)
 {
     if (e.ColumnName == Column.Name)
     {
         SetHeaderCheckbox();
         StateHasChanged();
         await Task.CompletedTask;
     }
 }
 private async Task RowCheckboxChanged(CheckboxEventArgs <T> e)
 {
     if (e.ColumnName == Column.Name)
     {
         if (Column.HeaderCheckbox)
         {
             if (GridComponent.ExceptCheckedRows.Get(Column.Name).Values.Where(r => r == true).Count()
                 == GridComponent.Grid.ItemsCount ||
                 (_allChecked == true &&
                  GridComponent.ExceptCheckedRows.Get(Column.Name).Values.Where(r => r == false).Count() == 0))
             {
                 _allChecked     = true;
                 _showAllChecked = true;
                 GridComponent.ExceptCheckedRows.AddParameter(Column.Name, new QueryDictionary <bool>());
             }
             else if (GridComponent.ExceptCheckedRows.Get(Column.Name).Values.Where(r => r == false).Count()
                      == GridComponent.Grid.ItemsCount ||
                      (_allChecked == false &&
                       GridComponent.ExceptCheckedRows.Get(Column.Name).Values.Where(r => r == true).Count() == 0))
             {
                 _allChecked     = false;
                 _showAllChecked = true;
                 GridComponent.ExceptCheckedRows.AddParameter(Column.Name, new QueryDictionary <bool>());
             }
             else
             {
                 _showAllChecked = false;
             }
         }
         else
         {
             _allChecked     = null;
             _showAllChecked = false;
         }
         _shouldRender = true;
         StateHasChanged();
         await Task.CompletedTask;
     }
 }
Beispiel #6
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();
            }
        }