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

onchange not wotk in edit form #77

Closed
EsmaeelAmarloo opened this issue Nov 22, 2023 · 4 comments
Closed

onchange not wotk in edit form #77

EsmaeelAmarloo opened this issue Nov 22, 2023 · 4 comments
Assignees

Comments

@EsmaeelAmarloo
Copy link

EsmaeelAmarloo commented Nov 22, 2023

Hi .when i use datepicker in editform tag "onChange" not work

sample Code

<EditForm Model="TmpModel">
	<InputPersianDatePicker Id="List_Persin_Date11"
	Visible="true"
	Disabled="false"
	PickerAlign="Align.Right"
	PickerOffsetTopPositionInPixels="1"
	InitialValueSetOnToday="false"
	Value ="@strDate"
	CalendarType="Calendar.SingleModeJalali"
	DigitType="DigitType.English"
	DateFormat="DateFormat.yyyy_slash_MM_slash_dd"
	MinDateSetOnToday="false"
	Placeholder="مستقیم"
	CssClass="form-control mt-n3"
	Theme="PickerTheme.Default"
         OnChange="valueChanged"
	ReadOnly="false" />
</EditForm>
@farshaddavoudi
Copy link
Owner

Hi, thanks for contributing to the project and sharing the issue.

I'll take a look at this, but by saying the OnChange event not working, I'm assuming it won't fire at-all. Correct me if I'm wrong

@farshaddavoudi
Copy link
Owner

farshaddavoudi commented Nov 23, 2023

I think your problem will resolve if you use bind-Value ="@strDate" instead of Value ="@strDate" in the component declaration. It's related to the Blazor concept, not my implementation and/or the EditForm component.

If you only need to set the initial value of a property, use Value="@MyVariable". If you want a two-way binding, allowing changes in the variable to automatically update the property and vice versa, use bind-Value="@MyVariable".

Please check it out and update me with the result.

farshaddavoudi added a commit that referenced this issue Nov 23, 2023
@EsmaeelAmarloo
Copy link
Author

i use dateOnly in my project then i cant bind it to string Type parameter.I create wrapper component for persianDatePicker with dateOnly parameter. for tow way binding for wrapper component, I need to handle "onchane" event in "persianDatePicker".

@farshaddavoudi
Copy link
Owner

farshaddavoudi commented Nov 26, 2023

I'm a little bit confused. The question is does the datepicker's OnChange work when the bind type is a variable of string type?

Assuming that's true, I think the best approach for you is using a helper string type property to bind to the datepicker and use that string variable and somehow get your primary DateOnly variable from that. I think depending on your project, you can use getter and setters for it or just convert the string to DateOnly when needed for example in Submit button. Sync the main DateOnly property with the helper string type property in the OnChange event can be an option, too.

Please let me know if you have further queries about my suggested approaches.

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

When branches are created from issues, their pull requests are automatically linked.

2 participants