jqgrid select box option set selected
i am using jqgrid and i am adding a row that contains fields: textbox and selectbox.
After adding a row by selecting the age from the dropdown, when i click on this row for editing, the age dropdown list must mark the selected value by default. How to achieve this ?
This is the code showing the columns data:
colModel:[
{name:'user_id',index:'user_id', width:150,align:"center",editable:false,editoptions:{readonl开发者_运维知识库y:true,size:10}},
{name:'user_name',index:'user_name', width:250, align:"left",editable:true,editoptions:{size:30}},
{name: 'Age', width: 40, editable: true, formatter: 'select',
edittype: 'select', editoptions: { value: age_list },
hidden: true, editrules: { edithidden: true }}
]
where 'age_list' is the array of age values in the form of a javascript array.
Use edittype: 'custom'
for your column, and then you can create your own html for the control:
<script>
jQuery("#grid_id").jqGrid({
...
colModel: [
...
{name:'price', ..., editable:true, edittype:'custom', editoptions:{custom_element: functionThatReturnsHtmlElement, custom_value: functionThatReturnsTheValueYouNeed} },
...
]
...
});
</script>
More details at jqGrid's documentation wiki: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules#editable
精彩评论