ASP.net
Awesome
Learn
Forum
Buy
Demos
Sign In
☾
☀
Switch to
Dark
Light
Mode
this site works best with javascript enabled
Ask Question
Change RadioList selection when datepicker changes value ?
Title:
B
I
{code}
?
I have a radio button list and a datepicker. When the value of the datepicker changes I need the value of the radiobuttonlist to change based on some condition. @Html.Awe().DatePicker("date1") @(Html.Awe().AjaxRadioListFor(m => m.tageID).Action("Tages").Controller("Home"))
Save Changes
Cancel
SalesARM
asked at 24 Feb 2019
Answers
B
I
{code}
?
You can do this by handling the `change` event (as you would do for basic html editors): $('#date1').on('change', function(){ var strval = $(this).val(); var dateval = $(this).data('api').getDate(); if(...) { $('#tageID').val(123).change(); } });
Save Changes
Cancel
Omu
answered at 25 Feb 2019
Your above solution is true if I know the output of radio list, but my list is dynamic. I cannot hardcode as $('#tageID').val(123).change(); I want to check the text of the binded button <btn type="button" cls="awe-btn awe-il " data-index="0" data-key="1">Open</button> For eg. Open in above case and then set value
at 25 Feb 2019
SalesARM
the way you're trying to do this looks like really bad design; anyway, you could get the list of items the ajaxradiolist is bound to by calling `$('#id').data('o').lrs`; you could also use this demo https://demo.aspnetawesome.com/AjaxDropdownDemo#Set-value-from-get-items-call as an example and do the whole thing on the server (datepicker would be the parent)
at 25 Feb 2019
Omu
great I will switch to this parent option that is correct approach, I'm not familiar with this one. The link you shared has been removed. can you provide a different link
at 25 Feb 2019
SalesARM
I've edited the comment
at 25 Feb 2019
Omu
thanks but based on this parent how can I set one of the value as default selected as my method is returning as :- var items = data.Select(o => new KeyContent(o.tageID, o.Name)); return Json(items); Is there a way to pass some default selected value at this time.
at 25 Feb 2019
SalesARM
yes, you can see that in the demo linked above (controller tab)
at 25 Feb 2019
Omu
thanks for the help !!
at 25 Feb 2019
SalesARM
@(Html.Awe().AjaxRadioListFor(m => m.tageID).ButtonGroup() .Parent(m => m.DefaultDate, "selectedDate") .Parent(m => m.DefaultTime, "selectedTime") .Parent("CurrentUserTime", "CurrentUserTime") public ActionResult Gettages(string selectedDate, string selectedTime, string CurrentUserTime) {} This is my structure in view Nd controller but my method gets called only on selectedDate change which is a datepicker but not on selectedTime change which is a timepicker. What can be the reason for this
at 25 Feb 2019
SalesARM
think in older versions the timepicker wasn't triggering change
at 25 Feb 2019
Omu
then any work around is there using javascript ?
at 25 Feb 2019
SalesARM
try using this https://demo.aspnetawesome.com/AjaxRadioListDemo#TimePicker instead
at 25 Feb 2019
Omu
Yes this is working but again I am stuck in major problem, in date picker when I am selecting the previous date from current date, I am able to post the page but when I am selecting the future date I am not able to post the mvc page ?
at 25 Feb 2019
SalesARM
Please provide any help for above mentioned problem ?
at 26 Feb 2019
SalesARM
think you're having problems with your project setup of jquery.validate
at 26 Feb 2019
Omu
I am using date picker as @Html.Awe().DatePickerFor(o => o.ActivityDate).ChangeMonth(true).ChangeYear(true).DateFormat("dd/MM/yyyy") On page submission this dateformat is creating problem , I tried removing it and everything worked fine, So I want to understand how can I keep it and post my page
at 26 Feb 2019
SalesARM
try removing jquery.validate
at 26 Feb 2019
Omu
please
Sign In
to leave an answer
By accessing this site, you agree to store cookies on your device and disclose information in accordance with our
cookie policy
and
privacy policy
.
OK