form参数化 jq,带参数化查询的jqGrid setSelect函数

I'm using jqGrid, on edit/add function I want to have a drop down list in one of these fields.

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

none of the above worked while having:

if(isset ($_REQUEST["tempid"]))

$rowid = jqGridUtils::Strip($_REQUEST["tempid"]);

else

$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.

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 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');

}

}

}

});

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值