Comments (17)
@sardar97 I'll fix your issue but I need your help. To be honest, from your video I don't understand what is going on at all. Can you create a minimal example code that reproduces your problem without all your application complexity? I can use that as a test case for creating a fix.
Since TryMB is still on v6.x.x you could checkout our dev branch and add a simple example to our treeview docs that exhibits the behavior you reported. Then either PR that example and tag me or post the example code here in this issue
from mudblazor.
Do you concur?
Yes.
Do we want to add it in v7 or v8?
Imo v7 would be better
from mudblazor.
I plan to PR it this weekend.
from mudblazor.
@sardar97 I'll fix your issue but I need your help. To be honest, from your video I don't understand what is going on at all. Can you create a minimal example code that reproduces your problem without all your application complexity? I can use that as a test case for creating a fix.
Since TryMB is still on v6.x.x you could checkout our dev branch and add a simple example to our treeview docs that exhibits the behavior you reported. Then either PR that example and tag me or post the example code here in this issue
see it here
I just used one of the examples in dev.mudblazor.com treeview docs
from mudblazor.
I understand your problem now. Your MudTreeView
has T="TreeItemData"
. When you set SelectedValues
to some other objects of TreeItemData
the treeview will find that it doesn't have matching values in its tree and thus nothing happens. You need to either set a comparer or implement GetHashCode()
and Equals()
on your TreeItemData class.
from mudblazor.
@ScarletKuro The problem we have here is related to our discussion a while ago. Treeview has a parameter
[Parameter]
[Category(CategoryTypes.TreeView.Data)]
public IReadOnlyCollection<T>? Items { get; set; } = Array.Empty<T>();
Which are then rendered in the treeview razor using the item template:
@foreach (var item in Items)
{
@ItemTemplate(item)
}
The problem here is that the Items
parameter now forces the treeview to become T="TreeViewData"
instead of for instance T="string"
which would be better suited for SelectedValues
.
I think we should provide a standard TreeItemData<T>
class which our users can inherit from and change Items
from type T
to TreeItemData<T>
.
Do you concur?
from mudblazor.
@ScarletKuro The problem we have here is related to our discussion a while ago. Treeview has a parameter
[Parameter] [Category(CategoryTypes.TreeView.Data)] public IReadOnlyCollection<T>? Items { get; set; } = Array.Empty<T>();Which are then rendered in the treeview razor using the item template:
@foreach (var item in Items) { @ItemTemplate(item) }
The problem here is that the
Items
parameter now forces the treeview to becomeT="TreeViewData"
instead of for instanceT="string"
which would be better suited forSelectedValues
.I think we should provide a standard
TreeItemData<T>
class which our users can inherit from and changeItems
from typeT
toTreeItemData<T>
.Do you concur?
yes I am, that really make sense.
from mudblazor.
I understand your problem now. Your
MudTreeView
hasT="TreeItemData"
. When you setSelectedValues
to some other objects ofTreeItemData
the treeview will find that it doesn't have matching values in its tree and thus nothing happens. You need to either set a comparer or implementGetHashCode()
andEquals()
on your TreeItemData class.
I tried this with my own codes it make sense for the parent only not for the child!
public class TreeItemData
{
public string Title { get; set; }
public string ParentName { get; set; }
public bool IsParent { get; set; }
public bool Expanded { get; set; }
public HashSet<TreeItemData> ChildItems { get; set; }
public TreeItemData(string title,string parentName,bool isParent)
{
Title = title;
ParentName = parentName;
IsParent = isParent;
}
public override bool Equals(object? obj)
{
return obj is TreeItemData data &&
Title == data.Title &&
ParentName == data.ParentName &&
IsParent == data.IsParent;
}
public override int GetHashCode()
{
return HashCode.Combine(Title, ParentName, IsParent);
}
}
![Screenshot 2024-06-06 at 9 53 08 AM](https://private-user-images.githubusercontent.com/96167344/337194816-38d39f11-f6d7-47e2-b4fe-74f44d9f22a6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkxMjc0NDIsIm5iZiI6MTcxOTEyNzE0MiwicGF0aCI6Ii85NjE2NzM0NC8zMzcxOTQ4MTYtMzhkMzlmMTEtZjZkNy00N2UyLWI0ZmUtNzRmNDRkOWYyMmE2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjIzVDA3MTkwMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBlNDgyYmZmMGUxYWE5MmYzZjAxOWFmYjA2YTE3YzRlZGRhZWUxNjRiMTIzZmRmOTc1ZGU0NTMxODI3MzgzMTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.oZqyGqXNLazwquqqL1pzM549Ik8OZL5K0GuTKSKASMA)
from mudblazor.
I think it would work if you just used the Title
for comparison.
public override bool Equals(object? obj)
{
return obj is TreeItemData data &&
Title == data.Title;
}
public override int GetHashCode()
{
return Title.GetHashCode();
}
Edit: or if they are not unique you'll need some kind of unique ID
from mudblazor.
I think it would work if you just used the
Title
for comparison.public override bool Equals(object? obj) { return obj is TreeItemData data && Title == data.Title; } public override int GetHashCode() { return Title.GetHashCode(); }Edit: or if they are not unique you'll need some kind of unique ID
Actually I don't have unique ID in my case and let me explain it.
I have this table which is from asp net core Identity and I want to get only claim value
and then separate claim values by "." like Kitchen is parent and creat,read,update,delete . however in this case the parent is kind of unique because it will never repeat for each role.
well again it is what I want to do is that I want group by parent and show creat,read,update,delete for child.
I hope this would be clear for you 😅
from mudblazor.
The claim value looks like a suitably unique ID
from mudblazor.
The claim value looks like a suitably unique ID
yeah but the problem is that I have to separate them for better user friendly ui and I don't really know how to handle it :(
from mudblazor.
It is easy. Add public string ID { get; set; }
to class TreeItemData
and save the claim value in the ID. Then use it for Equals and GetHashCode()
from mudblazor.
@henon look at this shadow issue as well.
Screen.Recording.2024-06-06.at.3.04.33.PM.mov
from mudblazor.
Browser rendering issue? I don't see how this could be a treeview bug.
from mudblazor.
yeah it is only in Safari has this issue.
from mudblazor.
Do you concur?
Yes.
Do we want to add it in v7 or v8?
from mudblazor.
Related Issues (20)
- MudThemeProvider needs to have interactivity mode
- MudDataGrid: Index out of bounds error when using TemplateColumn in a for loop HOT 2
- Drag element only with header
- Autocomplete with ItemTemplate won't register touch scroll events HOT 2
- NumericField: Hold spin buttons to keep increasing/decreasing HOT 2
- MudAutocomplete WASM does shows NoItemsTemplate on mouse click without keyboard input HOT 2
- GroupBy MudDataGrid Only Group if multiple rows
- MudAutocomplete: empty BeforeItemsTemplate occupies space and ruins layout by inserting empty div with padding in the popover list. HOT 4
- MudSelect with Enum Values doesn't display selected values HOT 4
- Expandable Items in MudSelect
- Timeline Icon Attribute Doesn't Work HOT 3
- MudFormComponent:ValidateWithAttribute ValidationContext prioritization HOT 2
- CSS property object-fit from MudImage gets overwritten by parent MudAvatar stylesheet
- Themes is Not working in Smaller Screen but works Fine in Larger Screen HOT 2
- MudChart component Width attribute percentage value does not work correctly
- MudDataGrid default Sortable based on whether property implements IComparable
- Datagrid filters inside dialog do not work HOT 1
- Add MudDataGridPager AllItemsText Property HOT 1
- Add SonarCloud integration to CI workflow HOT 24
- MudTabs slider has an issue with v7.0.0-rc and -rc2 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mudblazor.