GithubHelp home page GithubHelp logo

Comments (1)

gustavnavar avatar gustavnavar commented on June 8, 2024

The selected checkboxes are configured in the following ways:

  • checkboxes in the current page: with the GridComponent.Checkboxes property
  • global settings for all checkboxes in the all pages: with the GridComponent.ExceptCheckedRows property and with the IsCheched() method of the header component object.

These 2 mechanisms are implemented and configured by the GridBlazor component at the same time because their purpose is different, but complementary.

GridComponent.Checkboxes.Get("columnName") dictionary includes the checked boxes of the current page using the the row id of the page, starting by 0 for the first row, as key. Each time that the page is rendered this dictionary is initialized and each checkbox value is setted as follows using the global settings:

    bool _value = false;
    
    // init value when header checkbox is enabled and is not null
    var header = GridComponent.HeaderComponents.Get(_columnName);
    var exceptCheckedRows = GridComponent.ExceptCheckedRows.Get(_columnName);
    var keys = GridComponent.Grid.GetPrimaryKeyValues(Item);
    string stringKeys = string.Join('_', keys);
    if (exceptCheckedRows != null && !string.IsNullOrWhiteSpace(stringKeys) && exceptCheckedRows.ContainsKey(stringKeys))
        _value = exceptCheckedRows.Get(stringKeys);
    else if (header != null && header.IsChecked().HasValue)
        _value = header.IsChecked().Value;

As you can see the checkbox value is false by default.
Then if GridComponent.ExceptCheckedRows dictionary contains the row key, the value is the one on the dictionary.
If GridComponent.ExceptCheckedRows dictionary doesn't contain the row key but the header IsChecked returns a non null value, the checkbox value is this one.

If you want to get the checked rows value you can follow one of the following approaches:

  • disable paging to get all rows on the grid and use GridComponent.Checkboxes property to get the checked rows
  • enable paging and use ExceptCheckedRows and HeaderComponents properties to get the checked columns in the same described before.

from grid.blazor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.