如何使用 Flexigrid 在 asmx 中传递参数?

发布于 2024-09-10 21:20:39 字数 1425 浏览 5 评论 0原文

这是我的代码:

$('#flex1').flexigrid({
            method: 'POST',
            url: '/services/MHService.asmx/GetSurgicalHistory',
            dataType: 'xml',
            colModel: [
                    { display: 'Surgical Procedure', name: 'SurgicalProcedure', width: 120, sortable: true, align: 'left' },
                    { display: 'Notes', name: 'Notes', width: 120, sortable: true, align: 'left' },
                    { display: 'Complications', name: 'Complications', width: 120, sortable: true, align: 'left' }
                ],
            searchitems: [
                    { display: 'Surgical Procedure', name: 'SurgicalProcedure' },
                    { display: 'Notes', name: 'Notes' },
                    { display: 'Complications', name: 'Complications' }
                ],
            sortname: 'SurgicalProcedure',
            singleSelect: true,
            sortorder: 'asc',
            usepager: true,
            title: 'Surigcal History',
            useRp: true,
            rp: 10,
            showTableToggleBtn: true,
            width: 805,
            height: 200
        });

现在这个代码可以工作了,我如何在网络服务中传递参数?我尝试在 Flexigrid api 中查找“data”参数,但似乎没有。

像这样的东西:

            method: 'POST',
            url: '/services/MHService.asmx/GetSurgicalHistory',
            dataType: 'xml',
            data: '{ id: 23, area: "anywhere" }',

here's my code:

$('#flex1').flexigrid({
            method: 'POST',
            url: '/services/MHService.asmx/GetSurgicalHistory',
            dataType: 'xml',
            colModel: [
                    { display: 'Surgical Procedure', name: 'SurgicalProcedure', width: 120, sortable: true, align: 'left' },
                    { display: 'Notes', name: 'Notes', width: 120, sortable: true, align: 'left' },
                    { display: 'Complications', name: 'Complications', width: 120, sortable: true, align: 'left' }
                ],
            searchitems: [
                    { display: 'Surgical Procedure', name: 'SurgicalProcedure' },
                    { display: 'Notes', name: 'Notes' },
                    { display: 'Complications', name: 'Complications' }
                ],
            sortname: 'SurgicalProcedure',
            singleSelect: true,
            sortorder: 'asc',
            usepager: true,
            title: 'Surigcal History',
            useRp: true,
            rp: 10,
            showTableToggleBtn: true,
            width: 805,
            height: 200
        });

Now this code works, how do i pass parameters in the webservice? i tried looking for the 'data' parameter in the Flexigrid api, but there seems to be none.

something like this:

            method: 'POST',
            url: '/services/MHService.asmx/GetSurgicalHistory',
            dataType: 'xml',
            data: '{ id: 23, area: "anywhere" }',

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

凑诗 2024-09-17 21:20:39

更改:

data: '{ id: 23, area: "anywhere" }',

为:

params: [{name:'id', value: 23},{name:'area', value: 'anywhere'}],

或者如果您想使用新选项重新加载:

$("#flex1").flexOptions({params: [{name:'id', value: 23},{name:'area', value: 'anywhere'}]}).flexReload();

Change:

data: '{ id: 23, area: "anywhere" }',

to:

params: [{name:'id', value: 23},{name:'area', value: 'anywhere'}],

Or if you want to reload with new Options:

$("#flex1").flexOptions({params: [{name:'id', value: 23},{name:'area', value: 'anywhere'}]}).flexReload();
抚你发端 2024-09-17 21:20:39

可以使用 params: 选项指定其他参数。如果查看 flexigrid.js 中的第 615-618 行,您可以看到代码在 p.params 中循环每个项目的位置,并将其添加到默认列表(page、rp、sortname 等)。

Additional parameters can be specified using the params: option. If you look at line 615-618 in flexigrid.js, you can see where the code loops through each item in p.params, and adds it to the default list (page, rp, sortname, etc).

故乡的云 2024-09-17 21:20:39

我最终做的是这个
在 flexigrid.js 的第 713 行上,我添加了这个

            for(opt in p.optional){
              param[param.length] = {name:opt,value:p.optional[opt]};
            }

,然后我可以做这样的事情,这

 $('#flex1').flexigrid({
        method: 'POST',
        url: '/services/MHService.asmx/GetSurgicalHistory',
        dataType: 'xml',
        colModel: [
                { display: 'Surgical Procedure', name: 'SurgicalProcedure', width: 120, sortable: true, align: 'left' },
                { display: 'Notes', name: 'Notes', width: 120, sortable: true, align: 'left' },
                { display: 'Complications', name: 'Complications', width: 120, sortable: true, align: 'left' }
            ],
        searchitems: [
                { display: 'Surgical Procedure', name: 'SurgicalProcedure' },
                { display: 'Notes', name: 'Notes' },
                { display: 'Complications', name: 'Complications' }
            ],
        sortname: 'SurgicalProcedure',
        singleSelect: true,
        sortorder: 'asc',
        usepager: true,
        title: 'Surigcal History',
        useRp: true,
        rp: 10,
        showTableToggleBtn: true,
        width: 805,
        height: 200,
        optional: { id: 23, area: "anywhere" }
    });

不是很好,但我真的可以找到任何其他方法,而且我没有看到任何新版本很快就会出现 8 ^ )

what I ended up doing was this
on line 713 of flexigrid.js i add this

            for(opt in p.optional){
              param[param.length] = {name:opt,value:p.optional[opt]};
            }

then I could do something like this

 $('#flex1').flexigrid({
        method: 'POST',
        url: '/services/MHService.asmx/GetSurgicalHistory',
        dataType: 'xml',
        colModel: [
                { display: 'Surgical Procedure', name: 'SurgicalProcedure', width: 120, sortable: true, align: 'left' },
                { display: 'Notes', name: 'Notes', width: 120, sortable: true, align: 'left' },
                { display: 'Complications', name: 'Complications', width: 120, sortable: true, align: 'left' }
            ],
        searchitems: [
                { display: 'Surgical Procedure', name: 'SurgicalProcedure' },
                { display: 'Notes', name: 'Notes' },
                { display: 'Complications', name: 'Complications' }
            ],
        sortname: 'SurgicalProcedure',
        singleSelect: true,
        sortorder: 'asc',
        usepager: true,
        title: 'Surigcal History',
        useRp: true,
        rp: 10,
        showTableToggleBtn: true,
        width: 805,
        height: 200,
        optional: { id: 23, area: "anywhere" }
    });

its not great but I really could find any other way and I don't see any new versions coming out anytime soon 8 ^ )

戏蝶舞 2024-09-17 21:20:39

您应该在这里尝试一下:

http://bargaorobalo.net/blog/flexigrid-passar-parametros

它是葡萄牙语,但意味着您将附加参数传递给 json:

useRp   : true,
rp  : 10,
params: [{name:'ID', value: 100}]

并在 json 设置变量中接收:

$query     = isset($_POST['query'])     ? $_POST['query']    : false;
$qtype     = isset($_POST['qtype'])     ? $_POST['qtype']    : false;
$id = isset($_POST['ID']) ? $_POST['ID'] : NULL;

现在,您只需在 SQL 代码中使用此参数:

$sql = "SELECT * FROM PROCEDURE_NAME(".$id.") $where $sort $limit";
$result = runSQL($sql);

You should try this here:

http://bargaorobalo.net/blog/flexigrid-passar-parametros

Its in portuguese, but means that you PASS additionals parameters to json:

useRp   : true,
rp  : 10,
params: [{name:'ID', value: 100}]

and RECEIVE in json setting variable:

$query     = isset($_POST['query'])     ? $_POST['query']    : false;
$qtype     = isset($_POST['qtype'])     ? $_POST['qtype']    : false;
$id = isset($_POST['ID']) ? $_POST['ID'] : NULL;

Now, you just use this parameter in your SQL CODE:

$sql = "SELECT * FROM PROCEDURE_NAME(".$id.") $where $sort $limit";
$result = runSQL($sql);
蓝梦月影 2024-09-17 21:20:39

如果您尝试在某些单击事件中加载特定值的 Flexigrid 数据。试试这个
一样使用查询字符串

 var val1=value;
    url: '/services/MHService.asmx/GetSurgicalHistory?qurid='+val1,

我们可以像webservice 方法

,并使用字符串getvalue=HttpContext.Current.Request.QueryString["qurid"].ToString(); 从 webservice 获取

if you try to load flexigrid data for a particular value in some click Event. try this
we can use the query string like a

 var val1=value;
    url: '/services/MHService.asmx/GetSurgicalHistory?qurid='+val1,

to the webservice method and get from webservice using string

getvalue=HttpContext.Current.Request.QueryString["qurid"].ToString();

童话 2024-09-17 21:20:39

初始化flexigrid时,您可以在onSubmit事件中使用flexOptions,如下所示:

...
title: 'Surigcal History',
onSubmit: function() {  
  $('#flex1').flexOptions({newp:1,params:[{name: 'id', value: '23'}]});
  $('#flex1').flexOptions({newp:1,params:[{name: 'area', value: 'anywhere'}]});
},
useRp: true,
...

最好对多个参数使用循环

这可以避免直接修改flexigrid.js

You can use the flexOptions in the onSubmit event when initializing flexigrid, like this:

...
title: 'Surigcal History',
onSubmit: function() {  
  $('#flex1').flexOptions({newp:1,params:[{name: 'id', value: '23'}]});
  $('#flex1').flexOptions({newp:1,params:[{name: 'area', value: 'anywhere'}]});
},
useRp: true,
...

better to use a loop for multiple parameters

This avoids modifying the flexigrid.js directly

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文