Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datagrid Checkbox Column Header #1749

Closed
pvagnini opened this issue Jan 26, 2021 · 14 comments
Closed

Datagrid Checkbox Column Header #1749

pvagnini opened this issue Jan 26, 2021 · 14 comments

Comments

@pvagnini
Copy link

Hi,
Great set of tools thanks.

For a Datagrid with a Checkbox Column being used as row selection is there any way to render a Checkbox in the Header that can be used to then select / deselect all rows please?

Thanks

@stsrki
Copy link
Collaborator

stsrki commented Jan 26, 2021

We already have multi selection mode by using checkboxes in one of the latest 0.9.3 previews. It is set simply by <DataGrid SelectionMode="DataGridSelectionMode.Multiple">

If you want to try it here is the guide https://github.com/stsrki/Blazorise#try-preview

@pvagnini
Copy link
Author

pvagnini commented Jan 26, 2021 via email

@stsrki
Copy link
Collaborator

stsrki commented Jan 26, 2021

You have that option

image

Also, check 093 demo for reference https://github.com/stsrki/Blazorise/blob/dev093/Demos/Blazorise.Demo/Pages/Tests/DataGridPage.razor

@pvagnini
Copy link
Author

pvagnini commented Jan 26, 2021 via email

@stsrki
Copy link
Collaborator

stsrki commented Jan 26, 2021

Hi,

  1. I checked in code and it seems currently checked state is done with internal IsChecked property. Since @David-Moreira has done a multiselection feature maybe he can also answer how hard would it be to use an item field if it is defined?

  2. OnSelectedRowStyling works for me, I just tried it for both single and multi mode

image

  1. Use...() are completely removed in 0.9.3

@pvagnini
Copy link
Author

pvagnini commented Jan 26, 2021 via email

@stsrki
Copy link
Collaborator

stsrki commented Jan 26, 2021

Yes, previously row color was controlled with bg-primary class(for Boostrap), and it was wrong. So we fixed it to use table-primary class.

@David-Moreira
Copy link
Contributor

David-Moreira commented Jan 26, 2021

Great! Someone else interested in this feature! :)

So... I don't think we expose anything like IsSelected no, not on this feature, neither on the datagrid in general.
@stsrki correct me if I'm wrong.
The only thing that tells you what is selected, is the SelectedRow and the SelectedRows in the case of multi select being active.

From the top of my head, you have two ways.

  • You do a boolean check based on if your item is in the SelectedRows list
  • Otherwise you implement your own checkbox where you apply your own logic using the provided template. And still tell Datagrid when the selected has changed with the boolean value.
    Should be something like this, I haven't tested it:
    image

If you need more help with this just say so, and I can take a more detailed look when I have more time.

@pvagnini
Copy link
Author

pvagnini commented Jan 26, 2021 via email

@David-Moreira
Copy link
Contributor

Hi David,   Thanks for your response. Just to be clear the IsSelected property is part of my model and not something that should be implemented by the data grid.   I have previously used a generic column with a Check in the Display Template that binds to my property and works, but this is missing the ability to check all in the header.   What would be great would be if you could still bind the check value to a property in the model when using the MultiSelectColumn.   I will try your suggestion and see if I can get to work.   Thanks for your help. Paolo.   From: David [email protected] Sent: Wednesday, 27 January 2021 12:16 AM To: stsrki/Blazorise [email protected] Cc: Paolo Vagnini [email protected]; Author [email protected] Subject: Re: [stsrki/Blazorise] Datagrid Checkbox Column Header (#1749)   Great! Someone else interested in this feature! :) So... I don't think we expose anything like IsSelected no, not on this feature, neither on the datagrid in general. @stsrki correct me if I'm wrong. The only thing that tells you what is selected, is the SelectedRow and the SelectedRows in the case of multi select being active. From the top of my head, you have two ways. * You do a boolean check based on if your item is in the SelectedItems list * Otherwise you implement your own checkbox where you apply your own logic using the provided template. And still tell Datagrid when the selected has changed with the boolean value. Should be something like this, I haven't tested it: If you need more help with this just say so, and I can take a more detailed look when I have more time. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

I understand what you'd like to do. It's not what the feature was intended for, but maybe you can customize it enough with the template to get it working just how you'd like. The feature is to "select many" and then do operations based on the records selected. Not to promptly bind model information. For example I am currently using it to allow my user to select various records, based on a one to many relationship, so I can just do a bulk insert of all the selected records onto my storage, instead of having the user inserting one record at a time.

May I ask what is the final purpose of the IsSelected of your record?

Another idea, is that the user selects the records by using the multi select, and then you have a button the user clicks that goes through the selectedRows and sets your selected records to "IsSelected".
Then again, I would like to hear what you are trying to accomplish in concrete so I can give you some better ideas/possibilities. :)

@pvagnini
Copy link
Author

pvagnini commented Jan 27, 2021 via email

@David-Moreira
Copy link
Contributor

Seems like you can accomplish that with the template.
Just let us know, if you're not able, or need any help. :)

@pvagnini
Copy link
Author

pvagnini commented Jan 30, 2021 via email

@David-Moreira
Copy link
Contributor

Hello,
I can try to help you, but those more general questions, could be addressed with @stsrki :P

So, I'm guessing your problem is with the inputs the filters row have. You also have to also style them.

The following screenshot is just for demonstration purposes, you should not directly alter such a general class such as form-control, unless you really do want to do so or apply more css specificity, otherwise you should apply your own class to the filters inputs and make the desired changes:

image

@stsrki stsrki closed this as completed Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants