m是未定义的 - sorttable.js在三列上排序时

时间:2012-06-22 20:26:37

标签: javascript c# jquery sorttable.js

当我尝试对三列(状态,状态和队列)进行排序时,我收到一个javascript错误,指出m未定义(292超出范围32)。我不认为这个错误来自于sorttable.js文件。它指向我jquery.min.js文件。我不知道为什么这三列有问题,因为它们中的数据非常标准(只是单词,从不空白)。它似乎只是按上次成功排序的列进行排序。

以下是代码:

用户点击“开始”按钮 - 将ajax查询请求发送到另一个页面,该页面会填充结果。

function SubmitSearch() {
    $("#searchResults").html('<br/><center><img src="../Images/barberpole.gif" style="margin-top:3px;"></center>');

    //Deleted all initializing code. There is no problem with this.         

    $.ajax(
    {
        type: "POST",
        url: "../ajaxURLs/SearchRequests.aspx?requestID=" + requestID,
        cache: false,
        success: function (data) {
            $("#searchResults").html(data);
            sorttable.makeSortable(document.getElementById("SearchResults"));
        }
    });
}

<asp:GridView ID="SearchResults" runat="server" AutoGenerateColumns="False" DataKeyNames="requestNumber"  CSSClass="mailGrid" 
             OnRowDataBound="SearchRedirect">
                <Columns>
                  <asp:BoundField DataField="requestNumber" HeaderText="Request Number" InsertVisible="False" ReadOnly="True" />
                  <asp:BoundField DataField="state" HeaderText="State" />
                  <asp:BoundField DataField="status" HeaderText="Status" />
                  <asp:BoundField DataField="queue" HeaderText="Queue" />
                  <asp:BoundField DataField="oem" HeaderText="OEM"/>
                  <asp:BoundField DataField="rayMaterialNum" HeaderText="Material Number"/>
                  <asp:BoundField DataField="mfgPartNumber" HeaderText="Mfg Part Number"/>
                  <asp:BoundField DataField="program" HeaderText="Program"/>
                  <asp:BoundField DataField="purchaseOrder" HeaderText="Purchase Order" />
                  <asp:BoundField DataField="purchReq" HeaderText="Purchase Requisition"/>
                  <asp:BoundField DataField="businessUnit" HeaderText="Business Unit"/>
                  <asp:BoundField DataField="site" HeaderText="Site"/>
                  <asp:BoundField DataField="buyer" HeaderText="Buyer"/>
                  <asp:BoundField DataField="requisitioner" HeaderText="Requisitioner"/>
                  <asp:BoundField DataField="componentEngineer" HeaderText="Component Engineer"/>
                  <asp:BoundField DataField="responsibleEngineer" HeaderText="Responsible Engineer"/>
                  <asp:BoundField DataField="qualityEngineer" HeaderText="Quality Engineer"/>
                </Columns>
          </asp:GridView>

我正在使用sorttable.js的第2版,Firefox 13.0.1,jquery v1.7.2

生成的html:

<table id="SearchResults" class="mailGrid" cellspacing="0" border="1" style="border-collapse:collapse;" rules="all">
<thead>
<tr>
<th class=" " scope="col">Request Number</th>
<th class=" sorttable_sorted_reverse" scope="col">
<th class=" " scope="col">Status</th>
<th class="" scope="col">Queue</th>
<th class=" " scope="col">OEM</th>
<th class=" " scope="col">Raytheon Material Number</th>
<th class="" scope="col">Mfg Part Number</th>
<th class="" scope="col">Program</th>
<th class="" scope="col">Purchase Order</th>
<th class="" scope="col">Purchase Requisition</th>
<th class="" scope="col">Business Unit</th>
<th class="" scope="col">Site</th>
<th class="" scope="col">Buyer</th>
<th class="" scope="col">Requisitioner</th>
<th class="" scope="col">Component Engineer</th>
<th class="" scope="col">Responsible Engineer</th>
<th class="" scope="col">Quality Engineer</th>
</tr>
</thead>
<tbody>
<tr onclick="ViewRequest('2000')">
<tr onclick="ViewRequest('2001')">
<tr onclick="ViewRequest('2002')">
<tr onclick="ViewRequest('2003')">
<tr onclick="ViewRequest('2004')">
<tr onclick="ViewRequest('2005')">
<tr onclick="ViewRequest('2006')">
<tr onclick="ViewRequest('2007')">
<tr onclick="ViewRequest('2008')">
<tr onclick="ViewRequest('2009')">
<tr onclick="ViewRequest('2010')">
<tr onclick="ViewRequest('2011')">
<tr onclick="ViewRequest('2012')">
<tr onclick="ViewRequest('2013')">
<tr onclick="ViewRequest('2014')">
<tr onclick="ViewRequest('2015')">
<tr onclick="ViewRequest('2016')">
<tr onclick="ViewRequest('2017')">
</tbody>
<tfoot></tfoot>
</table>

其中一个tr的例子。它们都遵循这种格式,所讨论的列将始终包含数据。

<tr onclick="ViewRequest('2000')">
<td>2000</td>
<td>Open</td>
<td>Initiated</td>
<td>Buyer</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>0</td>
<td>0</td>
<td>0179450</td>
<td>Pending</td>
<td>Pending</td>
<td>Pending</td>
<td>Pending</td>
</tr>

1 个答案:

答案 0 :(得分:1)

据我所知,你应该将class =“sortable”添加到你想要排序的任何表中,也许这可以解决问题。