Comments (11)
Hi.
After updating from Version 6.17 to either 6.18 of 6.19.1,
Are you sure in your statement?
I copy pasted your code, downgraded to 6.17.0 and it doesn't work, I downgraded to 6.2.3 and it doesn't work.]
But it works just fine when I have a normal class that holds the DateTime
even with the current version.
https://try.mudblazor.com/snippet/QkcSapOLVIZXjWGP
from mudblazor.
This is tricky to explain, but it's expected behavior.
In your snippet you directly declare List<DateTime?>
, the issue arises because DateTime
is a value type, this means that each time it's accessed a copy will be created, therefore when you are editing it you are not working anymore with the "original" DateTime
. However in my snippet I wrap the DateTime
within a class Item
and therefore working with a reference type.
I hope you do understand the difference between a class and a struct.
from mudblazor.
Thank you so much for getting back to me so soon.
Yes sorry my mistake I was trying to simplify the actual example and saw the behavior of not updating was the same and assumed I had done a good job.
I have updated my test code to more closely resemble the actual code I am having an issue with after the MudBlazor Update until I found the issue happening. Then I took most of it out again ensuring the issue still existed. I still may be doing something incorrect but it turns out after the update I am only having the trouble when utilizing the DatePicker Property TextChanged
Here is my updated test using your working example as a base.
https://try.mudblazor.com/snippet/caQSYJuCniMeLjum
Please let me know if I should be doing something different or if this is a bug.
Thanks again for your time.
Kind regards
Shane
from mudblazor.
From your code sample, I think this is the reason. When this method get called StartDateChanged(Item? item), it still have the old value passed to it. So the data bind event of the grid happens after StartDateChanged.
from mudblazor.
Hi again.
Any reason you are not satisfied with the @bind-Date="context.Item.Value"
without TextChanged
? I would say this is the only correct way to do it.
From your code sample, I think this is the reason. When this method get called StartDateChanged(Item? item), it still have the old value passed to it. So the data bind event of the grid happens after StartDateChanged.
This is correct.
You expect that the DataGrid will mutate context.Item
and you receive the modified one but DataGrid doesn't touch this context. It will somewhere internally deep clone it and modify and use if needed but it's not exposed anywhere(and this will actually happen using only the Form
mode, in Cell
mode DataGrid is not even aware how the data is being modified by custom EditTemplate
).
For the TextChanged
to work you'd need to do something like this:
https://try.mudblazor.com/snippet/mOweEzOCSuAZJMPA
I haven't yet tested if this indeed worked in previous versions, but I'd be surprised if it did and I actually don't recall any DataGrid changes for the EditTemplate
, but I will check when I get time.
from mudblazor.
I haven't yet tested if this indeed worked in previous versions, but I'd be surprised if it did and I actually don't recall any datagrid changes for the
EditTemplate
, but I will check when I get time.
The only thing I can think of, is that earlier the bind-Date
and TextChanged
worked at same time, and the two way binding was modifying the Value
and when StartDateChanged
fires it was having than new value. Now the . But @bind-Date
doesn't work when TextChanged
is usedTextChanged
doesn't really make sense to me when you are using @bind-Date
from mudblazor.
@henon @Anu6is this change #8382 "broke" it.
It's hard to say if I'm more leaning towards it to be a feature than a bug, since I'm still thinking that OP is using the code incorrectly.
It looks like my above assumption is correct:
Before the change the sequence would be: TextChanged -> DateChanged -> TextChanged -> DateChanged
After the change the sequence is: TextChanged -> TextChanged -> DateChanged -> DateChanged
Don't ask me why the events are firing twice, I guess it's another mublazor bug with the "call the eventhandler in the setter" and something is triggering it twice. But you still shouldn't rely on this sequence side effects on what fires first, that's why I probably wouldn't do anything with the #8382 but let me know what ya all think.
from mudblazor.
I think the component just needs some attention. Update to the new parameter state usage and see if any of the logic can be streamlined/simplified
from mudblazor.
Thanks for the Info, to give you an idea of why I am using TextChanged as well as @bind-Date. If the full code I actually use PickerClosed as well but that event is still working as before.
The @bindDate is bound to a date property of an object that is a part of a collection assigned to the grid. @bind-Date updates the value perfectly well, but I am looking for an event to have the modification of that date affect other dates in the collection to make user input easier.
For example in the actual code the object has a StartDate and an EndDate, when the user updates the start date depending on if they used a text change or a picker change we are catching that event and updating the equivalent finished date. With out the individual event for the specific date being changed it would be difficult to determine which date was changed in the larger object to know which end date to update.
Let me know if this doesn't make sense I can update an example further to illustrate if you like.
Kind regards
Shane
from mudblazor.
With out the individual event for the specific date being changed it would be difficult to determine which date was changed
Do I understand correct that you just need an event when the binding is updated?
Use:
<MudDatePicker @bind-Date="date" @bind-Date:after="DateUpdated" />
Unfortunately the :after
doesn't work in trymudblazor, but it should in project with .net7 and higher.
from mudblazor.
Great, thanks! you learn something new every day.
That is working, I'm going to need to work on my Error notifications on the DatePicker now as they seem to now appear in times that they did using the old method but the date is updating and the corresponding date is being updated correctly as well.
Thank you!
from mudblazor.
Related Issues (20)
- DatePicker and Time Picker does not set value once they are tabbed
- MudSelect Does not Select Item on Keystroke
- CheckBox is not edge-aligned with other common inputs HOT 4
- MudOverlay: Remove `OnClick` callback HOT 5
- Dark Reader plugin and MudThemeProvider.GetSystemPreference() cause error HOT 1
- KeyInterceptor: Simplify setup HOT 8
- MudTextField blocks input with applied custom RegexMak
- Data Grid; include sort options in Filter Popover
- DataGrid; Support to un-hide columns through ui HOT 1
- DataGrid: Control supported operators for filters per column
- DataGrid; Removing a filter from the filter popover causes the DataGrid to refresh; refresh should only occur when selecting "apply" ?
- DataGrid; Selecting the filter menu or filter icon causes the filter to be added even if the user does not configure the filter and select's apply
- MudSwitch doesn't allow a default value when using ValueChanged HOT 5
- Make palette classes immutable `record`s
- Improve accessibility of default palette HOT 5
- Unify Radio, Check Box, Switch
- Typography: Allow strings in all settings
- MudBlazor template is missing unhandled exceptions div HOT 6
- DataGrid: SortDefinitions paramter is ignored
- MudRadioButton and MudCheckbox Not working in Register page HOT 6
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.