开发者

.setPostData jqgrid not working

I want to reload jqgrid with new parameters.I'm using .setPostData().Please look at my code below.It always give me error at .setPostData().M I missing something? format?

$('table[id$="'+tabID+'_BBGrid"]').jqGrid({ 
    url:'/Controls/Advertiser/BBControlNew.ascx.ashx?action=getBBData&advertiserID=' + $('#advertiser_id').text() + '&startDate=' + $('input[id$="' + tabID +
 '_FromCalBuyBack_CalendarTbx"] ').val() + '&endDate=' + $('input[id$="' + tabID + '_ToCalBuyBack_CalendarTbx"] ').val(),
    datatype: 'json',
    mtype: 'POST', 
    height:'100%',
    width:'100%',
    colNames: result.colNamesData, 
    colModel: result.colModelData,
    //pager: '#RequestLeadspager', 
    rowNum : 100,
    shr开发者_开发百科inkToFit :false,
...........
function  BuyBackGridReload(tabID,NoSelectedValues)
{
    $('table[id$="'+tabID+'_BuyBackGrid"]').setPostData({
        advertiserID:$('#advertiser_id').text(),
        CampaignsDdlSelectedValue: $('select[id$="CampaignDdl"] option:selected').val(),
        startDate: $('input[id$="'+tabID+'_FromCalBuyBack_CalendarTbx"] ').val(),
        endDate: $('input[id$="'+tabID+'_ToCalBuyBack_CalendarTbx"] ').val(),
        NoSelectedValue: NoSelectedValues
    }).trigger("reloadGrid");
};

I have search btn.I'm getting values for NoSelectedValues inside that search btn. here is the code for button click. $('input[id$="'+tabID+'_BuyBackSearchBtn"]').click(function(){

var values = [];

$('div[id$="' + tabID + '_SelectedBuyBackFilterDiv"] .children').each(function (){
     $(this).find('option').each(function (){
       var attr = $(this).attr('rel');
       if (typeof attr == 'undefined' ){
         values.push($(this).val());
       }
     });
});
BuyBackGridReload(tabID,values);

}); //End search click

ERROR:

$("table[id$=\"" + tabID + "_BuyBackGrid\"]").setPostData({advertiserID: $("#advertiser_id").text(), CampaignsDdlSelectedValue: $("select[id$=\"CampaignDdl\"] option:selected").val(), startDate: $("input[id$=\"" + tabID + "_FromCalBuyBack_CalendarTbx\"] ").val(), endDate: $("input[id$=\"" + tabID + "_ToCalBuyBack_CalendarTbx\"] ").val(), NoSelectedValue: NoSelectedValues}) is undefined

I also don't want to pass as a querystring for new parameters.

Any suggestion?

Thanks

A


You don't need to use setPostData to set the postData parameter. You can use setGridParam function instead. See here examples.

I suppose if you will use postData parameter which contain functions you will not need to set any postData parameter at all. The url and postData parameters of jqGrid can look like

url:'/Controls/Advertiser/BBControlNew.ascx.ashx",
postData: {
    action: "getBBData"
    advertiserID: function() { return $('#advertiser_id').text(); },
    startDate: function() { return $('input[id$="' + tabID + '_FromCalBuyBack_CalendarTbx"] ').val(); },
    endDate: function() { return $('input[id$="' + tabID + '_ToCalBuyBack_CalendarTbx"] ').val(); },
    advertiserID: function() { return $('#advertiser_id').text(); },
    CampaignsDdlSelectedValue: function() { return $('select[id$="CampaignDdl"] option:selected').val(); },
    startDate: function() { return $('input[id$="'+tabID+'_FromCalBuyBack_CalendarTbx"] ').val(); },
    endDate: function() { return $('input[id$="'+tabID+'_ToCalBuyBack_CalendarTbx"] ').val(); },
    NoSelectedValue: function() { return NoSelectedValues; }
}

The variables tabID and NoSelectedValues must be defined before. On every grid reloading the function from every postData property will be called and you can read the current values from the corresponding controls.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜