how do you pass parameters in asmx using Flexigrid?

最后都变了- 提交于 2019-12-05 20:24:30

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 ^ )

Cesar

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

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

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);
Karthick Raja

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!