Jq Grid Edit创建不可编辑的控件

时间:2016-08-01 13:26:36

标签: c# jquery asp.net

使用JQ网格。

我的Jq网格将进入JQ对话框。

当我点击编辑时弹出即将出现,但控件不可编辑。

JQ Grid的Java脚本:

$(document).ready(function () {
        $('.viewIcon').click(function () {

            $(function () {
                $("#jqtable").dialog({
                    title: "Admin Console",
                    resizable: false,
                    modal: true,
                    width: 'auto',
                    appendTo: "form",
                    open: function (event, ui) {


                        jQuery("#jQGridDemo").jqGrid({
                            url: 'api/AdminConsole/GetListDetailData',
                            datatype: "json",
                            colNames: ['Key', 'Value'],
                            colModel: [
                            { name: 'Key', index: 'Key', width: 200, align: "left", editable: true },
                            { name: 'Value', index: 'Value', width: 200, align: "left", editable: true, edittype: 'text' },
                            ],
                            jsonReader: {
                                repeatitems: true,
                                page: function () { return 1; },
                                root: function (obj) { return obj.rows; },
                                records: function (obj) { return obj.length; }
                            },

                            pager: "#jqGridPager"


                        });

                        $("#jQGridDemo").jqGrid('navGrid', '#jqGridPager',
                                          {
                                              add: true,
                                              edit: true,
                                              del: true
                                          });






                    },


                });
            });

        });
    });



    $("#jqtable").dialog("open");

对话框显示like this and content are non editable.

的用户界面

1 个答案:

答案 0 :(得分:0)

我找到了答案

添加以下代码

$(document).ready(function(){

public class ParseNewsFeed implements ParseNewsFeedContract {
    private Context mContext;

    public ParseNewsFeed(Context context) {
        if(context != null) {
            Timber.d("mContext != null");
            mContext = context;
        }
    }

    /**
     * Get the json from the local resource file and add to the cache to save loading each time
     * @return the json in string representation
     */
    @Override
    public void getJsonFromResource(Events<Status> events) {
        /* Get the json in string format */
        final String jsonString = loadNewsFeed();

        /* Check that is contains something */
        if(!jsonString.isEmpty()) {
            try {
                final Status status = new Gson().fromJson(jsonString, Status.class);
                if(status != null) {
                    Timber.d("url: %s", status.getResults().get(0).getMultimedia().get(0).getUrl());
                    events.onNewsSuccess(status);
                }
                else {
                    Timber.e("status == null");
                    events.onNewsFailure("Failed to get results from json");
                }
            }
            catch (JsonSyntaxException e) {
                Timber.e("Invalid JSON: %s", e.getMessage());
                events.onNewsFailure(e.getMessage());
            }
        }
    }

    /**
     * Opens and reads from the news_list and writes to a buffer
     * @return return the json representation as a string or a empty string for failure
     */
    public String loadNewsFeed() {
        InputStream inputStream = mContext.getResources().openRawResource(R.raw.news_list);
        Writer writer = new StringWriter();
        char[] buffer = new char[1024];

        try {
            InputStreamReader inputReader = new InputStreamReader(inputStream, "UTF-8");
            BufferedReader bufferReader = new BufferedReader(inputReader);
            int n;
            while ((n = bufferReader.read(buffer)) != -1) {
                writer.write(buffer, 0, n);
            }

            inputStream.close();
        }
        catch (IOException ioException) {
            return "";
        }

        return writer.toString();
    }
}