我正在使用 jqGrid,在编辑/添加功能上,我希望在这些字段之一中有一个下拉列表.
I'm using jqGrid, on edit/add function I want to have a drop down list in one of these fields.
如果我使用 setSelect 函数,这会起作用:
This works if i use the setSelect function as this:
$grid->setSelect("title", "SELECT DISTINCT name,name as TestingName FROM template", true, true, false, array(""=>"All"));
如何将参数传递给我的查询?我试过这些:
How can I pass parameters to my query? I tried these:
1-"SELECT DISTINCT name,name as TestingName FROM template where tempid = ?"
2- "SELECT DISTINCT name,name as TestingName FROM template where tempid = $rowid"
3-"SELECT DISTINCT name,name as TestingName FROM template where tempid = ".$rowid
以上都没有奏效:
if(isset ($_REQUEST["tempid"]))
$rowid = jqGridUtils::Strip($_REQUEST["tempid"]);
else
$rowid = "";
如果我正确理解您的问题,请使用 editoptions 和 dataUrl
.您想要具有附加参数 tempid
的 URL,其值应该是当前选定行的 rowid.
If I correct understand your question you use editoptions with dataUrl
. You want to have the URL which has additional parameter tempid
which value should be the rowid of the current selected row.
根据您问题的语法,我假设您使用了来自 trirand.net.在这种情况下,您应该使用标签 [jqgrid-php].jqGrid 是纯 JavaScript 开源产品.所以我回答你如何在 JavaScript 中添加 dataUrl
参数.
From the syntax of your question I suppose that you use some commercial jqGrid for PHP product from trirand.net. In the case you should use tag [jqgrid-php]. jqGrid is pure JavaScript open source product. So I answer how you can add dataUrl
parameter in JavaScript.
jqGrid 有 ajaxSelectOptions 选项,可用于修改使用dataUrl
的调用的jQuery.ajax
选项.您可以执行以下操作
jqGrid has ajaxSelectOptions option which can be used to modify the jQuery.ajax
options of the call which use dataUrl
. You can do following
var myGrid = $("#list");
myGrid.jqGrid({
// all your current parameters of jqGrid and then the following
ajaxSelectOptions: {
data: {
tempid: function () {
return myGrid.jqGrid('getGridParam', 'selrow');
}
}
}
});
如果jQuery.ajax的data
参数包含每次调用相应的 jQuery.ajax
时都会调用一个方法而不是属性.我在 答案.
If the data
parameter of jQuery.ajax contain a method instead of a property the method will be called every time of the corresponding jQuery.ajax
call. I used the same trick in the answer.
这篇关于jqGrid setSelect 函数与参数化查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!