I am working on JQGrid load complete for set filter default value for gs_tblAppBudgetStatus drop down to "Approved" then will reload the grid base on the new set default value result displayed on the grid as below, however my code doesn't work toward what
i needed:-
if you are using a current verion of jquery, you are not setting the selected option correctly. also if you set the selection, the <select> will fire a change event, you do not need to fire one (unless you are setting the same option selected and want to
fake a change event). also as id shoudl be unique you don't need the select, it just slows down the query.
micnie2020
Member
306 Points
524 Posts
Dropdownbox value selected but didn't fire onchange function
Feb 22, 2013 07:10 AM|LINK
Hi All,
I have use Jquery to select the dropdownbox value but seems trigger onchange not fire. Please advise.
My code as below:
$("select#gs_tblAppBudgetStatus option[value='Approved']").attr("selected", "selected");
$("select#gs_tblAppBudgetStatus").trigger('change');
or
$("select#gs_tblAppBudgetStatus option[value='Approved']").attr("selected", "selected").trigger('change');
Thank you.
Regards,
Micheale
S.Maire
Participant
904 Points
207 Posts
Re: Dropdownbox value selected but didn't fire onchange function
Feb 22, 2013 07:16 AM|LINK
Have you try this :
$("select#gs_tblAppBudgetStatus").change();micnie2020
Member
306 Points
524 Posts
Re: Dropdownbox value selected but didn't fire onchange function
Feb 22, 2013 07:22 AM|LINK
Hi,
Tried and NOT work too.
Thank you.
Regards,
Micheale
MetalAsp.Net
All-Star
112219 Points
18266 Posts
Moderator
Re: Dropdownbox value selected but didn't fire onchange function
Feb 22, 2013 07:25 AM|LINK
What are you expecting that code to do? Also, show your ddl markup.
micnie2020
Member
306 Points
524 Posts
Re: Dropdownbox value selected but didn't fire onchange function
Feb 22, 2013 07:43 AM|LINK
Hi All,
I am working on JQGrid load complete for set filter default value for gs_tblAppBudgetStatus drop down to "Approved" then will reload the grid base on the new set default value result displayed on the grid as below, however my code doesn't work toward what i needed:-
loadComplete: function (data) {
if ($("#gs_tblAppBudgetStatus").val() == "" || $("#gs_tblAppBudgetStatus").val() == null || $("#gs_tblAppBudgetStatus").val() == "underfine") {
$("#edit5_list1_top").addClass('ui-state-disabled');
$("#edit5_list1").addClass('ui-state-disabled');
$("#edit4_list1_top").addClass('ui-state-disabled');
$("#edit4_list1").addClass('ui-state-disabled');
$("select#gs_tblAppBudgetStatus option[value='Approved']").attr("selected", "selected");
}
$("#list1")[0].triggerToolbar();
if ($("#gs_tblAppBudgetStatus").val() == "Approved") {
$("#edit5_list1_top").removeClass('ui-state-disabled');
$("#edit5_list1").removeClass('ui-state-disabled');
}
},
Please advise.
Thank you.
Regards,
Micheale
bruce (sqlwo...
All-Star
36870 Points
5450 Posts
Re: Dropdownbox value selected but didn't fire onchange function
Feb 24, 2013 09:43 PM|LINK
if you are using a current verion of jquery, you are not setting the selected option correctly. also if you set the selection, the <select> will fire a change event, you do not need to fire one (unless you are setting the same option selected and want to fake a change event). also as id shoudl be unique you don't need the select, it just slows down the query.
try:
$("#gs_tblAppBudgetStatus option[value='Approved']").prop("selected", true);