Forum


Hello,
If I have 2 rows, each one of them contains id,name,sex
name = text input
sex = select menu (male, female)
the rows:
1, Jet Li, male
2, Nicole Kidman, female
now if I click on edit the second row it will show the editable inputs with the default option of the select menu which is male, while it is not, it is female "Nicole Kidman"... how can I make it read the selected option to view it in the edit page?
my code
{name:'Sex',index:'Sex', width:70, editable: true,edittype:"select",editoptions:{value:"1:male;2:female"},
is there anyway to change the previous bold text to let it read the selected option and make it as default then show the other options?
or at least make it select (in the edit page) the selected option (which was in the view page)?
thanks a lot 🙂
hi garnett21,
Well, I can show the selected values in the grid. but my question was,
when I click on edit the row. it gives me the available editable inputs and when it comes to the select menu. it shows the first option as selected option instead of the real selected option which has been stored in the database.
So, how can I let it shows the selected option in the edit pop-up form ?
I hope you understand what I was trying to say..
thanks a lot.
00:56

02/08/2008

if you store in your databas thing such as "male" or "female" and give jqGrid
select value "{value:”1:male;2:female”}," i don't think it will work. You have to give {value:”male:male;female:female”} as select value if you want it work.
The first item of each values of your jqGrid select must match with the value stores in your database.,
03:38

Moderators
30/10/2007

Try this
{value:”'1':male;'2':female”}
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.
Hi guys..
let me try to explain with my source..
This is my html code:
[CODE]<script type=”text/javascript”>
var dsPathJS = '{dsDir.0}{dsCONF.DIR.JAVA}/grid/'
jqGridInclude(dsPathJS);
jQuery(document).ready(function(){
jQuery(”#dsTable”).jqGrid({
colNames:[
'ID',
'{dsLANG.FULL_NAME} ({dsLANG.ARABIC})',
'{dsLANG.FULL_NAME} ({dsLANG.ENGLISH})',
'{dsLANG.SEX}',
'{dsLANG.FILE_NO}',
'{dsLANG.REF_NO}',
'{dsLANG.SALARY}',
'{dsLANG.CONTRACT}',
'{dsLANG.PASSPORT_NO}',
'{dsLANG.PLACE_OF_ISSUE} ({dsLANG.ARABIC})',
'{dsLANG.PLACE_OF_ISSUE} ({dsLANG.ENGLISH})',
'{dsLANG.DATE_OF_ISSUE}',
'{dsLANG.DATE_OF_EXPIRE}',
'{dsLANG.NATIONALITY}',
'{dsLANG.RELIGION}',
'{dsLANG.OCCUPATION}',
'{dsLANG.BIRTH_PLACE} ({dsLANG.ARABIC})',
'{dsLANG.BIRTH_PLACE} ({dsLANG.ENGLISH})',
'{dsLANG.BIRTH_DATE}',
'{dsLANG.MARITAL_STATUS}',
'{dsLANG.CHILDREN}',
'{dsLANG.HEIGHT}',
'{dsLANG.WEIGHT}',
'{dsLANG.EDU_QUALIFICATION} ({dsLANG.ARABIC})',
'{dsLANG.EDU_QUALIFICATION} ({dsLANG.ENGLISH})',
'{dsLANG.KNOWLEDGE_OF_ARABIC}',
'{dsLANG.KNOWLEDGE_OF_ENGLISH}',
'{dsLANG.EXPERIENCE}',
'{dsLANG.COUNTRIES_OF_WORK_B4} ({dsLANG.ARABIC})',
'{dsLANG.COUNTRIES_OF_WORK_B4} ({dsLANG.ENGLISH})',
'{dsLANG.SKILLS}',
'{dsLANG.ADDITIONAL_DATAS} ({dsLANG.ARABIC})',
'{dsLANG.ADDITIONAL_DATAS} ({dsLANG.ENGLISH})'
{dsSkillsColNames}
],
colModel:[
{name:'ID',index:'ID', width:40,editable:false,editoptions:{readonly:true,size:10}},
{name:'arName',index:'arName', width:135,editable:true,editoptions:{size:36}},
{name:'enName',index:'enName', width:140,editable:true,editoptions:{size:36}},
{name:'Sex',index:'Sex', width:70, editable: true,edittype:"select",editoptions:{value:"{dsSelect.Sex}"}},
{name:'fileNo',index:'fileNo', width:100,editable:true,editoptions:{size:36}},
{name:'refNo',index:'refNo', width:100,editable:true,editoptions:{size:36}},
{name:'Salary',index:'Salary', width:60,editable:true,editoptions:{size:36}},
{name:'Contract',index:'Contract', width:65,editable:true,editoptions:{size:36}},
{name:'passportNo',index:'passportNo', width:110,editable:true,editoptions:{size:36}},
{name:'arIssuePlace',index:'arIssuePlace', width:155,editable:true,editoptions:{size:36}},
{name:'enIssuePlace',index:'enIssuePlace', width:165,editable:true,editoptions:{size:36}},
{name:'issueDate',index:'issueDate', width:100,editable:true,editoptions:{size:36},sorttype:"date"},
{name:'issueExpiry',index:'issueExpiry', width:105,editable:true,editoptions:{size:36},sorttype:"date"},
{name:'Nationality',index:'Nationality', width:110, editable: true,edittype:"select",editoptions:{value:"{dsSelect.Nationality}"}},
{name:'Religion',index:'Religion', width:80, editable: true,edittype:"select",editoptions:{value:"{dsSelect.Religion}"}},
{name:'Occupation',index:'Occupation', width:100, editable: true,edittype:"select",editoptions:{value:"{dsSelect.Occupation}"}},
{name:'arBirthPlace',index:'arBirthPlace', width:160,editable:true,edittype:"text",editoptions:{size:36}},
{name:'enBirthPlace',index:'enBirthPlace', width:160,editable:true,edittype:"text",editoptions:{size:36}},
{name:'birthDate',index:'birthDate', width:100,editable:true,editoptions:{size:36},sorttype:"date"},
{name:'Status',index:'Status', width:100, editable: true,edittype:"select",editoptions:{value:"{dsSelect.Status}"}},
{name:'Children',index:'Children', width:70,editable:true,editoptions:{size:36}},
{name:'Height',index:'Height', width:55,editable:true,editoptions:{size:36}},
{name:'Weight',index:'Weight', width:55,editable:true,editoptions:{size:36}},
{name:'arEducation',index:'arEducation', width:230,editable:true,editoptions:{size:36}},
{name:'enEducation',index:'enEducation', width:235,editable:true,editoptions:{size:36}},
{name:'Arabic',index:'Arabic', width:150, editable: true,edittype:"select",editoptions:{value:"{dsSelect.Knowledge}"}},
{name:'English',index:'English', width:155, editable: true,edittype:"select",editoptions:{value:"{dsSelect.Knowledge}"}},
{name:'Experience',index:'Experience', width:80,editable:true,editoptions:{size:36}},
{name:'arExpCountries',index:'arExpCountries', width:230, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"5",cols:"35"}},
{name:'enExpCountries',index:'enExpCountries', width:235, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"5",cols:"35"}},
{name:'Skills',index:'Skills', width:200,editable:false,editoptions:{size:36}},
{name:'arDetails',index:'arDetails', width:180, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"5",cols:"35"}},
{name:'enDetails',index:'enDetails', width:180, sortable:false,editable: true,edittype:"textarea", editoptions:{rows:"5",cols:"35"}}
{dsSkillsColModel}
],
url:'?dsOption=show',
editurl:”?dsOption=modify”,
datatype: “json”,
mtype: 'POST',
rowNum:10,
rowList:[5,10,15,20,25,50],
pager: jQuery('#dsBar'),
imgpath: dsPathJS+'themes/basic/images',
viewrecords: true,
sortname: 'ID',
sortorder: “desc”,
recordtext: “Rows”,
caption:”{dsLANG.LIST_EMPLOYEES}”,
multiselect:false,
loadtext: “{dsLANG.AJAX_LOADING}”,
height:'190'
}).navGrid('#dsBar',
{edit:false,add:false,del:false}, //options
{
top:10,left:100,height:400,width:500,reloadAfterSubmit:false,
onInitializeForm: function(formid) {
$(”#birthDate”,formid).datepicker({dateFormat:”dd{dsCONF.SET.DSEP}mm{dsCONF.SET.DSEP}yy”});
$(”#issueDate”,formid).datepicker({dateFormat:”dd{dsCONF.SET.DSEP}mm{dsCONF.SET.DSEP}yy”});
$(”#issueExpiry”,formid).datepicker({dateFormat:”dd{dsCONF.SET.DSEP}mm{dsCONF.SET.DSEP}yy”});
}
}, // edit options
{
top:10,left:100,height:400,width:500,reloadAfterSubmit:true,
onInitializeForm: function(formid) {
$(”#issueDate”,formid).datepicker({dateFormat:”dd{dsCONF.SET.DSEP}mm{dsCONF.SET.DSEP}yy”});
$(”#issueExpiry”,formid).datepicker({dateFormat:”dd{dsCONF.SET.DSEP}mm{dsCONF.SET.DSEP}yy”});
$(”#birthDate”,formid).datepicker({dateFormat:”dd{dsCONF.SET.DSEP}mm{dsCONF.SET.DSEP}yy”});
}
}, // add options
{reloadAfterSubmit:false}, // del options
{} // search options
);
$(”#dsEditEmployee”).click(function(){
var gr = jQuery(”#dsTable”).getGridParam('selrow');
if( gr != null ) jQuery(”#dsTable”).editGridRow(gr,{
top:10,left:100,height:400,width:500,reloadAfterSubmit:false,
onInitializeForm: function(formid) {
$(”#birthDate”,formid).datepicker({dateFormat:”dd{dsCONF.SET.DSEP}mm{dsCONF.SET.DSEP}yy”});
$(”#issueDate”,formid).datepicker({dateFormat:”dd{dsCONF.SET.DSEP}mm{dsCONF.SET.DSEP}yy”});
$(”#issueExpiry”,formid).datepicker({dateFormat:”dd{dsCONF.SET.DSEP}mm{dsCONF.SET.DSEP}yy”});
}
});
else alert(”Please Select Row”);
});
$(”#dsAddEmployee”).click(function(){
jQuery(”#dsTable”).editGridRow(”new”,{
top:10,left:100,height:400,width:500,reloadAfterSubmit:true,
onInitializeForm: function(formid) {
$(”#issueDate”,formid).datepicker({dateFormat:”dd{dsCONF.SET.DSEP}mm{dsCONF.SET.DSEP}yy”});
$(”#issueExpiry”,formid).datepicker({dateFormat:”dd{dsCONF.SET.DSEP}mm{dsCONF.SET.DSEP}yy”});
$(”#birthDate”,formid).datepicker({dateFormat:”dd{dsCONF.SET.DSEP}mm{dsCONF.SET.DSEP}yy”});
}
});
});
$(”#dsDeleteEmployee”).click(function(){
//IDs in array
//var dsEmpID = jQuery(”#dsTable”).getGridParam('selarrrow');
//just one ID
var dsEmpID = jQuery(”#dsTable”).getGridParam('selrow');
//getSelectedRow();
if( dsEmpID != null ) jQuery(”#dsTable”).delGridRow(dsEmpID,{reloadAfterSubmit:false});
else alert(”Please Select Row to delete!”);
});
jQuery(”#dsImagesEmployee”).click( function() {
var dsEmpID = jQuery(”#dsTable”).getGridParam('selrow');
open_url('?dsOption=images&id='+dsEmpID,'dsAjaxImages');
});
</script>
<div dir=”ltr” style=”margin:0;padding:0;width:100%;overflow:auto;border:0px solid #222;”>
<table id=”dsTable” class=”scroll” cellpadding=”0″ cellspacing=”0″ style=”margin:0;padding:0;max-height:250px”></table>
</div>
<div dir=”ltr” style=”margin-top:2px;height:21px;width:350px;display:block;overflow:hidden;border:1px solid #259EBF;”>
<div id=”dsBar” class=”scroll” style=”text-align:left;”></div>
</div>
<div id=”dsAjaxImages” style=”margin:30px 10px 30px 10px;”></div>[/CODE]
and this is my php code: (the viewing page (grid))
[PHP]<?php
Function dsGridSelect($dsAttArr=Array(),$dsAttVar='') {
If(Empty($dsAttArr)||!$dsAttArr||!Is_Array($dsAttArr)||Empty($dsAttVar)||!$dsAttVar||!Array_Key_Exists($dsAttVar,$dsAttArr)) Return False;
$dsReturn = “-1:;”;
ForEach($dsAttArr[$dsAttVar] As $dsID => $dsVal) {
$dsReturn .= $dsID.':'.$dsVal.';';
}
$dsReturn = substr($dsReturn,0,strlen($dsReturn)-1);
Return $dsReturn;
}
$dsArEnVal = $dsLANG['AR_EN'].'Value';
$SQL = “SELECT ID,Variable,$dsArEnVal FROM “.$dsCONF['SQL']['PRFX'].”dsValues ORDER BY ID”;
$dsAttSQL = $ds->dsSQL->upQuery($SQL) or Die(”Couldn t execute query.”.mysql_error());
$dsAttVal = Array();
While($dsRow = $ds->dsSQL->upFetchObject($dsAttSQL)) {
$dsAttVal[$dsRow->Variable][$dsRow->ID] = trim(stripslashes($dsRow->$dsArEnVal));
}
$ds->dsSQL->upFreeResult();
$SQL=$dsAttSQL=$dsRow='';
$dsSelect = Array(
'Sex' => $ds->dsFunc->dsGridSelect($dsAttVal,'Sex'),
'Status' => $ds->dsFunc->dsGridSelect($dsAttVal,'Status'),
'Knowledge' => $ds->dsFunc->dsGridSelect($dsAttVal,'Knowledge'),
'Religion' => $ds->dsFunc->dsGridSelect($dsAttVal,'Religion'),
'Nationality' => $ds->dsFunc->dsGridSelect($dsAttVal,'Nationality'),
'Occupation' => $ds->dsFunc->dsGridSelect($dsAttVal,'Occupation')
);
$dsSkillsColNames=$dsSkillsColModel='';
ForEach($dsAttVal['Skills'] As $dsID => $dsVal) {
$dsSkillsColNames .= “,'$dsVal'”;
$dsCleanVal = 'Skills_'.str_replace(' ','_',str_replace('-','_',str_replace('.','_',$dsVal)));
$dsSkillsColModel .= “,{name:'$dsCleanVal', index:'$dsCleanVal', editable:true, edittype:\\”checkbox\\”, editoptions:{value:\\”Yes:No\\”}, hidden:true, editrules:{edithidden:true} }”;
}
Die($ds->dsFunc->dsOutPut('employee_list.html'));
?>[/PHP]
they are working just fine.. but when i click on edit the row from the tool bar (dsBar) it shows the editable inputs with their values.. but the select menu. it shows all the options without the default selected option..
i just wonder how can i make it select the selected option in the select menu
I hope I could explain well..
Thanks a lot for your helping guys
Most Users Ever Online: 715
Currently Online:
78 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