jqgrid OnComplete运行函数不起作用

时间:2011-03-29 16:34:04

标签: jquery jqgrid

我试图在jqgrid将数据从服务器输入网格后运行一个函数。被调用的函数将csrf标记更新为下一个jqgrid请求的全局变量。

$("#customer_grid").jqGrid({
    mtype: 'POST',
    url:'jqgrid/customer',
    postData: { <?php echo $csrf_token_name; ?>: csrf_token },
    datatype: 'json',
    colNames:['Account #', 'Firstname', 'Surname','Postcode','Address 1','Address 2', 'Address 3', 'City', 'County',
                'Country', 'Email', 'Home Tel', 'Mobile Tel', 'Work Tel'],
    colModel :[
      {name:'id', index:'id', width:80},
      {name:'firstname', index:'firstname', width:80},
      {name:'surname', index:'surname', width:80},
      {name:'postcode', index:'postcode', width:80},
      {name:'address_1', index:'address_1', width:80},
      {name:'address_2', index:'address_2', width:80},
      {name:'address_3', index:'address_3', width:80},
      {name:'city', index:'city', width:80},
      {name:'county', index:'county', width:80},
      {name:'country', index:'country', width:65},
      {name:'email', index:'email', width:80},
      {name:'home_tel', index:'home_tel', width:80},
      {name:'mobile_tel', index:'mobile_tel', width:80},
      {name:'work_tel', index:'work_tel', width:80},
    ],
    emptyRecords: "No Accounts Found",
    pager: '#customer_grid_pager',
    rowNum:10,
    rowList:[5,10,25,50,100],
    rownumbers: true,
    sortname: 'id',
    sortorder: 'desc',
    viewrecords: true,
    gridview : true,
    caption: 'Customer Search',
    height: '220',
    autowidth: true,
    onComplete: function(data, response) {
          get_csrf_token();
          alert(csrf_token);
    },
    ondblClickRow: function(id, row, column){              
          //alert('Hello World '+ id + ' ' + row + ' ' + column);
          customer_id = id;
          //alert(customer_id);
          crud_action = 'update';
          $('#new_customer').show();
          $('#customer_search').hide();
          customer_crud('read');
          show('#details');
    }



  });

Firebug没有显示javascript错误,并且get_csrf_token()没有被调用,任何想法?

由于

2 个答案:

答案 0 :(得分:1)

我没有将onComplete列为jqGrid event。您确定不想使用gridCompleteloadComplete吗?

答案 1 :(得分:1)

您应该使用此gridComplete: function(data, response) { get_csrf_token(); alert(csrf_token); },