This is a migrated thread and some comments may be shown as answers.

GridCheckboxColumn make all check boxes Checked on Load

6 Answers 877 Views
Grid
This is a migrated thread and some comments may be shown as answers.
const
Top achievements
Rank 2
Veteran
const asked on 17 Jun 2020, 09:02 PM

Hi,

How do I make all/some Check Boxes selected on Grid Load?

Is there "Value" or "Selected" property of that component?

Something like:

                        <GridColumns>
                            <GridCheckboxColumn Selected="true"/>

                       </GridColumns>

Please advise

 

6 Answers, 1 is accepted

Sort by
0
const
Top achievements
Rank 2
Veteran
answered on 18 Jun 2020, 03:52 AM

OK, I found the answer in posts:

https://www.telerik.com/forums/checkbox-column-f1b24f092353#vwso5nJgMU6DijCGVMzx8Q

The summary is: "The GridCheckboxColumn is used only for row selection, not for data binding/display."

Then I have another question: is there a way to select Row(s) from code during Grid rendering?

 

0
Accepted
Marin Bratanov
Telerik team
answered on 18 Jun 2020, 06:19 AM

Hello,

The Blazor way of doing that is to use a collection that controls the selected items. Please start by reviewing the available documentation we have on that:

So, you can populate the SelectedItems collection when fetching the data which happens before the grid renders. Another alternative is using the grid state to store the user choice or to populate selected items there: https://docs.telerik.com/blazor-ui/components/grid/state.

As for the name of the column and how it works, you may find interesting the following requests, so you can Vote for them to raise their priority and Follow them to know when they get implemented:

 

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
const
Top achievements
Rank 2
Veteran
answered on 18 Jun 2020, 03:35 PM

Grid State is really great and powerful method of Grid management!

Great implementation of Great Idea, Gents!

So, as I understood, I'm still able to manipulate a Grid values.

Like here: https://demos.telerik.com/blazor-ui/ (Edit Item demo):

    async Task EditItemFour()
    {
        var currState = GridRef.GetState();
        // reset any current insertion and any old edited items. Not mandatory.
        currState.InsertedItem = null;

        // add item you want to edit to the state, then set it to the grid
        SampleData itemToEdit = SampleData.GetClonedInstance(MyData.Where(itm => itm.ID == 4).FirstOrDefault());

        // you can alter values here as well (not mandatory)
        itemToEdit.Name = "Changed from code";

 
        currState.OriginalEditItem = itemToEdit;
        // for InCell editing, you can use the EditField property instead
        await GridRef.SetState(currState);
    }

Or GridCheckboxColumn is exemption?

Please advise.

0
const
Top achievements
Rank 2
Veteran
answered on 18 Jun 2020, 03:43 PM
... just to make it clear: I'm referencing Components/Grid/Grid State demo in post above ...
0
Accepted
Marin Bratanov
Telerik team
answered on 18 Jun 2020, 05:28 PM

Hello,

The GridCheckboxColumn is NOT a data column, it does not show data. It is all about selection of rows: https://feedback.telerik.com/blazor/1454771-rename-confusing-gridcheckboxcolumn.

So, to make those checkboxes selected, you must select rows. You can see how to do that here: https://docs.telerik.com/blazor-ui/components/grid/selection/multiple#two-way-binding-of-selecteditems.

If you want to pre-set editor values - then you must use a regular <GridColumn> and the values there will depend on the model values, so you don't have to use the state to alter them in the general case, doing it like in the example you copied might make sense in particular scenarios like upon editing/inserting  based on some custom logic.

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
const
Top achievements
Rank 2
Veteran
answered on 18 Jun 2020, 06:43 PM
that works for my purpose, thanks a lot!
Tags
Grid
Asked by
const
Top achievements
Rank 2
Veteran
Answers by
const
Top achievements
Rank 2
Veteran
Marin Bratanov
Telerik team
Share this question
or