来自JSON数据的JqGrid的colModel

时间:2014-09-25 16:00:55

标签: jquery json grails jqgrid

大家好我使用grails jqGrid插件。

我想通过AJAX响应传递colModel,但我不能这样做,请建议。这是我正在使用的代码。

$(document).ready(function() {
                var col_names = [];
                var col_model = [];    
                $.ajax({
              url: 'myURL',
              success: function(data) {
                col_names =  "'First Name', 'Last Name', 'E-mail', 'Country','id'";
                col_model =  "{name:'firstName', editable: true},{name:'lastName', editable: true},{name:'email', editable: true},{name:'country', editable: true},{name:'id', hidden: true}"
             }
     });
                             <jqgrid:grid
                              id="contact"
                              url="'${createLink(action: 'listJSON')}'"
                              async =true
                              editurl="'${createLink(action: 'editJSON')}'"
                              colNames = col_names 
                              colModel= col_model
                              sortname="'lastName'"
                              caption="'Contact List'"
                              height="300"
                              autowidth="true"
                              scrollOffset="0"
                              viewrecords="true"
                              showPager="true"
                              datatype="'json'">
                               <jqgrid:navigation id="contact" add="true" edit="true" 
                                    del="true" search="true" refresh="true" />
                              <jqgrid:resize id="contact" resizeOffset="-2" />
                       </jqgrid:grid>
             });

0 个答案:

没有答案