weixin_33698823 2014-01-24 17:39 采纳率: 0%
浏览 24

用ajax addrow jqxgrid

I'm trying to display the database in jqxgrid on page load using jquery, but the screen shows nothing.

I have a few pages to apply this technique to, and one of the page I've managed to do it using javascript. Then the second page is done using jquery. But on the third page (also using jquery), I get nothing.

this is the jquery in view_page.php:

<html>.... //view_page./
$(document).ready(function () {
 var param = '<?php echo $formdata->doc_num;?>';
 var array_grid_key = <?php echo json_encode($v_arrayGridKey2);?>;
 $.ajax({
  url:"<?php echo base_url('index.php/px/pxq/sel_head');?>/"+param,
  dataType: "json",
  success:function(result){
    var dataFields = new Array();   
    $("#ajax").html(result);                
    for(var i = 0;i<array_grid_key.length;i++){
      var obj = {name: array_grid_key[i]};
      dataFields.push(obj);
    }       
    var source = {
      datafields: dataFields,
      localdata: result
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    dataAdapter.dataBind();

    var dataSource = {
      datafields: dataFields,
      localdata: result
    };
    var adapter = new $.jqx.dataAdapter(dataSource);
    $("#data_grid").jqxGrid({ source: adapter });       
  }
 });
});
....</html>

this is the controller:

public function sel_head($code){
  $this->load->model('px');
    $this->data['ajax'] = $this->px->querying(  
    'select t3.code as \'code\', t3.name as \'name\', t2.item_d1 as \'item_d1\', t2.item_d2 as \'item_d2\',t2.item_qty as \'item_qty\', t2.item_price as \'item_price\', t2.item_disc_pct1 as \'item_disc_pct1\', t2.item_disc_pct2 as \'item_disc_pct2\',          t2.item_netprice as \'item_netprice\', t2.item_total as \'item_total\'          
        from spurc_h t1 
          inner join spurc_d t2 on t1.doc_id = t2.doc_id 
      inner join sttem_m t3 on t2.id = t3.id 
      inner join sbuss t4 on t4.buss_code = t1.buss_code
      where doc_num = \''.$code.'\''
    );
  echo json_encode($this->data['ajax']);
}

The most confusing part is why it works on 2nd page, but not on 3rd page.

Chrome developer tool shows it returns the query result as expected (json format), but we can't put it to the jqxgrid using the jquery above..

I want to use it as a tools, because so many pages need to be done like this. using the same technique will save the development time.

Please tell me what i miss here.. Appreciate your help :)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器