-1

我将以下代码写入 JQGrid 中的 Display TransactionList

<h2>Manage Transactions</h2>
<script language="javascript" type="text/javascript">

    $(document).ready(function () {
        $("#TransactionList").jqGrid({
            datatype: "local",
            height: 150,
            colNames: ['TransactionID', 'MinVersion', 'TransactionDateTime','RequestMessage','ResponseMessage','TransactionName','TransactionDescription','Enabled'],
            colModel: [
              { name: 'TransactionID', index: 'TransactionID', width: 60 },
              { name: 'MinVersion', index: 'MinVersion', width: 100 },
              { name: 'TransactionDateTime', index: 'TransactionDateTime', width: 400 },
              { name: 'RequestMessage', index: 'RequestMessage', width: 60 },
              { name: 'ResponseMessage', index: 'ResponseMessage', width: 60 },
              { name: 'TransactionName', index: 'TransactionName', width: 60 },
              { name: 'TransactionDescription', index: 'TransactionDescription', width: 60 },
              { name: 'Enabled', index: 'Enabled', width: 60 }
        ],               
            multiselect: true,
            ignoreCase: true,
            hidegrid: False ,            
            pager: '#gridpager',
            rowNum: 10,
            viewrecords: true,
            rowList: [10, 20, 30, 400]    
        });

        $.ajax({
            url: 'API/GetTransaction',
            type: 'post',
            data: null,
            beforeSend: function () {
            },
            success: function (response) {
                alert(response);
                $("#TransactionList").setGridParam({ data: response }).trigger("reloadGrid");
            },
            error: function (error) {
                alert(error);
            }
        });
        $("#TransactionList").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: "cn" });
    });

在上面的代码中,我的 javascript 不起作用。但,

<h2>Manage Transactions</h2>

正在浏览器上打印。任何人都可以帮我解决这个问题吗?

4

1 回答 1

1

您似乎没有带有 id 的元素TransactionList。首先添加:

<div id="TransactionList"></div>

然后从那里工作。

于 2012-08-28T13:32:43.153 回答