Forum


09:25

18/09/2008

Hi Tony,
I am new to use jQGrid and i think its awesome.Although i have difficulty in acheiving the following.When using Form Editing how to i dynamically change the form once it is loaded. For e.g.
colModel:[{name:'bbid',index:'bbid', width:40, sorttype:"int",hidden:true,editable: true},
{name:
'user',index:'user', width:130,editable:true,editoptions:{readonly:true,size:10}},
{name:
'person',index:'person', width:70,editable:true,hidden:true,editoptions:{readonly:true,size:10}},
{name:
'carrier',index:'carrier', width:70,edittype:"select",editable:true,editoptions:{value:"197:Verizon;198:T-Mobile"
} },
{name:
'model',index:'model', width:90,edittype:"select",editable:true,editoptions:{value:"1:7290;2:8700;3:8100;4:8800;5:8320;6:7250;7:8703;8:8830"
}},}).navGrid('#pager2',
{}, //options
{height:250}, // edit options
{height:250,closeAfterAdd:true,reloadAfterSubmit:true}, // add options
{url:
'Invoice?sort=delete'
}, // del options here it passes the id as the parameter
{} // search options
);
});
In the edit options when i change the option box (colname:'carrier') i want to load the next option box(colname:'model') with different values.
I tried doing something like this but did not work:
onInitializeForm: function(id){
jQuery('#list2).editrow(id,true,changeoption);
}
function changeoption(id){
//setcolprop...
}
Any help would be great...
Thanks
10:07

Moderators
30/10/2007

Hello,
Did you mean dpended listboxex?
Currently not possible, but simply you can do that easy using the same
event
something like
onInitializeForm : function (form_id) {
$("select#carrier",form_id).change(function() {
if( $(this).val() == "some_value") {
// chnge the values in the model of way what you want
}
})
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
17:12

13/11/2008

HI.
This seems to be similar to what I need. I have a few select boxes that need to change dynamically based on the previous selection, example, First choose country, next selct box shows only cities of that country, then choose city, next shows prvinces of that city… and so on.
Tony, I didn't quite understand what you meant. I have a field in the colum of edittype select say name:country.
onInitializeForm : function (form_id) {
$(”select#country”,form_id).change(function() {
if( $(this).val() == “some_value”)
{
//post to server and get value for cities…
}
});
All is good here, but then how do I change the options for the select name cities (for example).
Thanks to all in advance.
Cheers,
P.
07:42

Moderators
30/10/2007

Hello,
Imagine that there is no jqGrid. How will your code look like?
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
12:29

13/11/2008

Hi Tony.
My code without jqGrid, standard form looks something like this:
var delag_id = $("#delag").val();
$.post("'.$this->view->baseUrl().'/ajax/supselect",
{delag_id: delag_id}, function(data){
var options = "";
if (data == "false")
{
options += \\'<option value="0">Nenhum fornecedor criado.</option>\\';
}
else
{
obj = eval(\\'(\\' + data + \\')\\');
for (i = 0 ; i<obj["id"].length; i++)
{
options += \\'<option value="\\' + obj["id"][i] +
\\'">\\' + obj["name"][i] + \\'</option>\\';
}
}
$("select#supplier").html(options);
Then when the user selects a value from the second select (#supplier) the onchange triggers another post to the server fetching the next round ou values for a third select.
Any pointers as to how I go about this with a jqGrid form?
Cheers and thansk for all the help.
P.
06:40

Moderators
30/10/2007

Hello,
The same can be applied in onInitializeForm event -
i.e. define for the second select empty values (or what you want) and
apply this logic
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
16:45

13/11/2008

Hi diptendu.
This is how I got mine to work. I'm sure there may be better ways of doing this but here goes:
$("select#emp").change(function(){
$.post("/ajax/getcclist", { emp_id: +$("#emp").val()}, function(data){
var ccoptions = "";
if (data == "false")
{
ccoptions += \\'<option value="0">No Options Selected</option>\\';
}
else
{
obj = eval(\\'(\\' + data + \\')\\');
ccoptions += \\'<option value="0"></option>\\';
for (i = 0 ; i<obj["emp_id"].length; i++)
{
ccoptions += \\'<option value="\\' + obj["emp_id"][i] +
\\'">\\' + obj["code"][i]+" - "+obj["emp_name"][i] + \\'</option>\\';
}
}
$("select#ccusto").html(ccoptions);
});
});
You call this in the onInitializeForm event in your add/edit options.
Hope this helps some.
Cheers,
P.
Most Users Ever Online: 715
Currently Online:
57 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