代码之家  ›  专栏  ›  技术社区  ›  Martin Ongtangco

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

  •  3
  • Martin Ongtangco  · 技术社区  · 16 年前

    这是我的密码:

    $('#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
            });
    

    现在这段代码工作了,如何在webservice中传递参数?我试图在flexigridapi中查找'data'参数,但似乎没有。

    像这样:

                method: 'POST',
                url: '/services/MHService.asmx/GetSurgicalHistory',
                dataType: 'xml',
                data: '{ id: 23, area: "anywhere" }',
    
    6 回复  |  直到 16 年前
        1
  •  2
  •   mcgrailm    16 年前

    在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" }
        });
    

        2
  •  4
  •   dandan78 Tom Cool    14 年前

    更改:

    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();
    
        3
  •  3
  •   David Licorish    15 年前

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

        4
  •  1
  •   Bargão Robalo    14 年前

    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 = "SELECT * FROM PROCEDURE_NAME(".$id.") $where $sort $limit";
    $result = runSQL($sql);
    
        5
  •  0
  •   Nikhil Freddroid    13 年前

    如果尝试在某个单击事件中加载特定值的flexigrid数据。试试这个 我们可以像使用

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

    到webservice方法,并使用字符串从webservice获取

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

        6
  •  0
  •   kevyau    13 年前

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

    这样可以避免直接修改flexigid.js

    推荐文章