以下是我用来创建 jqGrid 的一段代码 -
$("#list").jqGrid({
url:'products.php?storeId=<?php echo $_SESSION["valid_store"]; ?>',
datatype: 'xml',
mtype: 'GET',
colNames:['Product Id','Product Description','Department','Category','Price','Sale Price','Quantity','Extended Description','Image'],
colModel :[
{name:'ProductId', index:'ProductId', width:20},
{name:'product_name', index:'product_name', width:50, editable:true, edittype:'text', search:true, stype:'text'},
{name:'DepartmentName', index:'DepartmentName', width:40,sortable: false, editable: true, edittype: "select"},
{name:'CategoryName', index:'CategoryName', width:40,sortable:false, editable:true, edittype:'select'},
当网格使用以下内容加载时,我正在动态填充“DepartmentName” -
var departments = $.ajax({
url: "get_departments.php?storeId=<?php echo $_SESSION["valid_store"]; ?>",
async: false,
success:function(data, result){
if(!result){
alert("Failure to retrieve the Departments");
}
}
loadComplete:function(){
$("#list").setColProp('DepartmentName', { editoptions: { value: departments} });
},
基本上,我将大量“部门”分配为 JSON 格式,当网格加载后,“部门名称”将填充所有这些部门。这一切都很好。
我在做什么/理解上有困难。现在我有了这些值,这取决于我从中选择的“部门” Select
,正在填充“类别名称”,仅使用所述“部门”引用的“类别”,数据之间的关系已经设置在MySQL
谢谢