我現在做了一些關於jqgrid的帖子,我得到了緩慢但肯定。jqgrid行id和gridrow ID
我產生了當網格完整功能生成網格中的每一行按鍵代碼:
gridComplete: function(){
var ids = jQuery("#rowed2").jqGrid('getDataIDs');
for(var i=0;i < ids.length;i++){
var cl = ids[i];
be = "<input style='height:22px;width:20px;' type='button' value='E' alt='Edit Location' onclick=\"jQuery('#rowed2').editGridRow('"+cl+"');\" />";
se = "<input style='height:22px;width:20px;' type='button' value='S' onclick=\"jQuery('#rowed2').saveRow('"+cl+"');\" />";
ce = "<input style='height:22px;width:20px;' type='button' value='C' onclick=\"jQuery('#rowed2').restoreRow('"+cl+"');\" />";
fl = "<input style='height:22px;width:50px;' type='button' value='Find' alt='Find Location' class='findMe' rel='"+cl+"' />";
gc = "<input style='height:22px;width:50px;' type='button' value='Geo' class='geocodeMe' rel='"+cl+"' />";
jQuery("#rowed2").jqGrid('setRowData',ids[i],{Actions:fl+gc});
}
}
我的編輯刪除它被張貼的jqGrid行ID作爲ID參數,它需要的功能成爲記錄集ID,以便我可以過濾要編輯/刪除的記錄。 所以我將id_〜mdt colulm設置爲key:true,因此它將此ID作爲ID傳遞。
現在我不能retrive使用網格行ID:(這是之前返回gridrow裁判,現在它返回的recordId)
ids = jQuery("#rowed2").jqGrid('getDataIDs');
讓我怎麼retrive的gridrowId現在???把我的按鈕的rel屬性
我假設我應該用其他的東西比getRowIds
像得到GridRowID
或東西,但不能在維基使用什麼發現?
gridComplete: function(){
var ids = jQuery("#rowed2").jqGrid('getDataIDs');
for(var i=0;i < ids.length;i++){
var cl = ids[i];
be = "<input style='height:22px;width:20px;' type='button' value='E' alt='Edit Location' onclick=\"jQuery('#rowed2').editGridRow('"+cl+"');\" />";
se = "<input style='height:22px;width:20px;' type='button' value='S' onclick=\"jQuery('#rowed2').saveRow('"+cl+"');\" />";
ce = "<input style='height:22px;width:20px;' type='button' value='C' onclick=\"jQuery('#rowed2').restoreRow('"+cl+"');\" />";
fl = "<input style='height:22px;width:50px;' type='button' value='Find' alt='Find Location' class='findMe' rel='"+cl+"' />";
gc = "<input style='height:22px;width:50px;' type='button' value='Geo' class='geocodeMe' rel='"+cl+"' />";
jQuery("#rowed2").jqGrid('setRowData',ids[i],{Actions:fl+gc});
}
}
});
我的繼承人完整的代碼與col設置:
myGrid = jQuery("#rowed2").jqGrid({
url:'data/stokistdata_s_json.php?q=3',
datatype: "json",
mtype: "POST",
rowNum:10,
rowList:[50,100,150,200,300,400,500,600],
pager: '#prowed2',
sortname: 'name_mdt',
viewrecords: true,
gridview:true,
sortorder: "asc",
rowNum:50,
scroll: true,
editurl: "data/server.php",
caption:"Stockist's and Orchid days",
colNames:[
'Actions',
'id',
'Type',
'Name',
'Geo Address',
'Display Address',
'Telephone',
'Email',
'website',
'lat',
'lng',
'flag',
'description',
'active'
],
colModel:[{
name:'Actions',
index:'Actions',
width:100,
sortable:false,
search:false
}, {
name:'id_mdt',
index:'id_mdt',
width:15,
align:"left",
sortable:true,
search:false,
hidden: true,
editable: true,
editrules: { edithidden: true },
editoptions:{readonly:true},
hidedlg: true,
key: true
}, {
name:'id_etp',
index:'id_etp',
width:90,
align:"left",
sortable:true,
editable:true,
edittype:"select",
formatter:'select',
editoptions:{value:{1:'Stokist',0:'Orchid Day'}},
editrules:{required:true},
search:true,
stype:'select',
sopt: ['eq'],
searchoptions:{value:{'':'All',1:'Stockist',2:'Orchid Day'}}
},{
name:'Name_mdt',
index:'Name_mdt',
align:"left",
width:150,
editable:true,
editrules:{required:true},
search:true,
stype:'text',
sopt:['cn']
}, {
name:'geoaddr_mdt',
index:'geoaddr_mdt',
width:150,
align:"left",
editable:true,
search:false,
edittype:"textarea",
editoptions:{rows:"3",cols:"30"}
}, {
name:'displayaddr_mdt',
index:'displayaddr_mdt',
width:150,
align:"left",
editable:true,
search:false,
edittype:"textarea",
editoptions:{rows:"3",cols:"30"}
}, {
name:'telephone_mdt',
index:'telephone_mdt',
width:80,
align:"left",
editable:true,
search:false
}, {
name:'email_mdt',
index:'email_mdt',
editrules:{email:true, required:false},
width:80,
align:"left",
sortable:false,
editable:true,
search:false
}, {
name:'website_mdt',
index:'website_mdt',
editrules:{url:true, required:false},
width:80,
align:"left",
sortable:false,
editable:true,
search:false
}, {
name:'lat_mdt',
index:'lat_mdt',
width:40,
align:"left",
sortable:false,
editable:true,
search:false
} , {
name:'lng_mdt',
index:'lng_mdt',
width:40,
align:"left",
sortable:false,
editable:true,
search:false
}, {
name:'flag_mdt',
index:'flag_mdt',
width:20,
align:"left",
sortable:true,
editable:true,
edittype:"select",
editoptions: {value:{1:'Flagged',0:'No Flag'}},
search:true,//
stype:'select',
searchoptions:{value:{'':'All',1:'Flagged',0:'No Flag'}}//{value:":Both;1:Flagged;0:No Flag"}
}, {
name:'description_mdt',
index:'description_mdt',
width:150,
align:"left",
sortable:false,
editable:true,
search:false,
edittype:"textarea",
editoptions:{rows:"3",cols:"30"}
}, {
name:'active_mdt',
index:'active_mdt',
width:20,
align:"left",
sortable:true,
editable:true,
edittype:"select",
editoptions: {value:{1:'Active',0:'Hidden'}},
search:true,//
stype:'select',
searchoptions:{value:{'':'All','1':'Active','0':'Hidden'}} //{value:":Both;1:Active;0:Hidden"}
}], search : {
caption: "Search...",
Find: "Find",
Reset: "Reset",
matchText: " match",
rulesText: " rules"
},
gridComplete: function(){
var ids = jQuery("#rowed2").jqGrid('getDataIDs');
for(var i=0;i < ids.length;i++){
var cl = ids[i];
be = "<input style='height:22px;width:20px;' type='button' value='E' alt='Edit Location' onclick=\"jQuery('#rowed2').editGridRow('"+cl+"');\" />";
se = "<input style='height:22px;width:20px;' type='button' value='S' onclick=\"jQuery('#rowed2').saveRow('"+cl+"');\" />";
ce = "<input style='height:22px;width:20px;' type='button' value='C' onclick=\"jQuery('#rowed2').restoreRow('"+cl+"');\" />";
fl = "<input style='height:22px;width:50px;' type='button' value='Find' alt='Find Location' class='findMe' rel='"+cl+"' />";
gc = "<input style='height:22px;width:50px;' type='button' value='Geo' class='geocodeMe' rel='"+cl+"' />";
jQuery("#rowed2").jqGrid('setRowData',ids[i],{Actions:fl+gc});
}
}
});
jQuery("#rowed2").jqGrid('navGrid',"#prowed2",
{edit:true,add:true,del:true,search:true,refresh:true},
{closeOnEscape:true, recreateForm: true, width:500},
{closeOnEscape:true, recreateForm: true, width:500} // Add options
);
myGrid.jqGrid('filterToolbar',{defaultSearch:'cn',stringResult:true});
});
嗯,我ahve的id_mdt山坳設置爲關鍵,沒有這個我不recive的分貝,這是需要編輯的記錄的行ID /刪除的功能,現在看來雖然我在我得到(jqg_899)或類似的id之前設置了這個id,現在我不會從網格jsut記錄id收回行id,我希望這樣做是有道理的,如果是的話,我會更新問題 – 2011-05-27 13:56:06
請記住, jqgrid rowid必須是唯一的,否則會混亂,因爲它會嘗試爲TR創建相同的ID。你可以簡單地通過儘可能多的ID或fiels,只要你想。如果你不想顯示列只是隱藏它 - >隱藏:真的 – LeftyX 2011-05-27 14:09:55
感謝澄清,我沒有意識到,網格行ID將採取與我的記錄集的主鍵ID相同,思考它,它使很多感! – 2011-05-30 09:42:32