Daragrid selection: How to set initial value of specific rows to selected / checked?

On load, how do I set datagrid to have certain rows already selected?

How are you populating the data?

If you’re doing it manually like this you should be able to just change the value to on or off. I’m not sure if there’s any caveats here though as I haven’t played around with the manual way.

If you’re binding a variable/collection to the data then you’ll need to make sure that your data has the key for your boolean column to be true or false

hey @Yaj i’m doing it automatically! t’s not a boolean column though - it’s the default selected column.

Having a look through the elements code I don’t believe it’s possible to do this. I could be wrong, but I only worked with the custom data and columns as I found the default stuff was less than helpful. I’ve actually forked the component code and updated it to make cell updating better and also find out how to do things like format the date values properly and have the option between auto width or fixed.

I could be wrong here but if you currently need this functionality I’d say you have to create custom columns, Make the first column the checkbox column with pinned as true. Then you can select which rows would have it to be as true by default.

I could be mistaken but there doesn’t look to be away to do this if you’re using row selection.

The datagrid element is great but it seems to lack alot right out of the box, even the documentation doesn’t explain how to do custom columns very well. I spent an hour trying to find any info out about the correct values I need for auto width vs fixed width, I ended up forking the componenet and finding what I needed in 2 minutes. I had much harder time figuring out how to format the date picker to show DD/MM/YYYY instead of YYYY-MM-DD

1 Like

I managed to solve this btw :smiley: by using a custom column. thank you!

2 Likes

Nice good to hear! Let me know if you have any questions with custom columns I’ve figured out how to do a few things which aren’t documented. But I have only really worked with the text,checkbox and date fields so anything else I’ll probably have to find time to look up how it works.

1 Like