0

我一直在为 jquery 尝试不同的 CRUD 网格,我遇到了这个非常好的。我使用不同的网格插件制作了之前的帖子,但这并没有满足我的需求,所以我正在尝试这个。表格显示正确,但行为空。

我从使用 JSON 在线验证器验证的服务器收到此响应

[{"id":"1","anio":"2016","mes":"1","quincena":"1"},{"id":"2","anio":"2016","mes":"1","quincena":"2"}]

这是 symfony 1.4 中用于构建 json 的脚本:

 public function executeGetNewsletters(sfWebRequest $request){

    $conn = Doctrine_Manager::getInstance()->getCurrentConnection();

    $qry=$conn->execute("Select id,anio,mes,quincena from newsletters");

            $newsletters = $qry;

            $dataNews = array();

                foreach ($newsletters as $news)
                    {

                           $dataNews[] = array(
                                "id" => $news['id'],
                                "anio" => $news['anio'],
                                "mes" => $news['mes'],
                                "quincena" => $news['quincena'],
                            );

                    }


            echo json_encode($dataNews);

              return sfView::NONE;





  }

这是保存网格的 js 文件:

$(document).ready(function(){   



    $("#newsletters").click(function(){$.ajax({
            type: "GET",
            url: "/newsletter/getNewsletters"
        }).done(function(newsletters) {

        //  newsletters.unshift({ id: "0", name: "" });

            var news=newsletters;

            alert(news);

            $("#jsGrid").jsGrid({
                height: "90%",
                width: "100%",
                datatype: 'json',        
                sorting: true,
                paging: true,
                filtering:true,
                autosearch: true,
                editing:true,
                autoencode: true,
                gridview: true,
                mtype: 'POST',
                colNames:['ID','Año', 'Mes','Quincena','Option'],

                data: news,

                fields: [
                    { name: "id", type: "number", width: 150 },
                    { name: "anio", type: "number", width: 50 },
                    { name: "mes", type: "number", width: 200 },
                    { name: "quincena", type: "text", textField: "Quincena" },
                    { type: "control" }
                ]
            });


        });
    });
});

这是包含网格的 html:

   <?php use_javascript("jurisprudencia/newsletter.js")?>

     <link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.4.1/jsgrid.min.css" />
     <link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.4.1/jsgrid-theme.min.css" />

     <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.4.1/jsgrid.min.js"></script>


    <body><div class="col-lg-7 col-lg-7-bc">
        <h3 style="font-size:20px"> JURISPRUDENCIA</h3>

        <p>

            </br>

        </p>


           <div class="col-xs-6 col-sm-4 item ico "><a id="newsletters" target="_blank">Newsletters |</a></div>

           <div class="col-xs-6 col-sm-4 item ico "><a  id="fallos" target="_blank">Navegar |</a></div>

           <div class="col-xs-6 col-sm-4 item ico"><a id="cuadernos_mpd" target="_blank">Cuadernos del MPD</a></div>


            <div id="jsGrid"></div>


     <script>

    </script>




    </div>

我在 jsgrid 文档中找不到可接受的格式。有谁知道哪个是正确的格式?谢谢

4

0 回答 0