Forum


00:41

20/08/2011

hi,
how can i get an existing select box to rebuild in one grid after i update the table it uses in another grid?
i have a select box in one editform with options for only those states that the client operates in. If the client goes to the administrative state grid to enable another operating state - then goes back to the editform of the first grid and clicks on the select box to view the operating states, the new operating state should be included in the select box list. It doesn't appear in the list because the select box has not been reloaded.
I tried triggering a reload of the first grid when the state grid is updated but the select box in the first grid does not reload along with the grid reload.
How can i get the select box to rebuild or should i be using another method?
thanks.
09:24

20/08/2011

Never mind, i figured it out…
I added an 'afterSubmit' event to the edit form of the state grid to test for and insert/remove the necessary select option from the work order add form's state select box.
// state table grid
, afterSubmit: updateStateSelect}, // edit options.
.
.
.
// javascript event.
// define handler function for 'afterSubmit' event.
var updateStateSelect = function(response,postdata){
var json = response.responseText; // responseText is returned form server as json object:{status:true,message:''}.
var result = JSON.parse(json); // convert json object into javascript object.
var rowid = $('#slt1-grid').getGridParam('selrow');
var active = $('input#us\.StateActive').attr('checked');
var stid = $('#slt1-grid').jqGrid('getCell', rowid, 'id'); // get the option value.
var statename = $('#slt1-grid').jqGrid('getCell', rowid, 'us.StateName'); // get the option label.
if(active){
if($('select#cu\.STID option[value="'+stid+'"]').length == 0){
$('select#cu\.STID').append('<option value="'+stid+'">'+statename+'</option>'); // append active option.
}
}else{
if($('select#cu\.STID option[value="'+stid+'"]').length > 0){
$('select#cu\.STID option[value="'+stid+'"]').remove(); // remove option if it exists.
}
}
return [result.status,result.message,result.newid];
}
Most Users Ever Online: 715
Currently Online:
61 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66