简体   繁体   中英

m is undefined - sorttable.js when sorting on three columns

When I am trying to sort on three columns (State, Status, and Queue), I get a javascript error that says m is undefined (292 out of range 32). I don't think that this error is getting originated in the sorttable.js file. It is pointing me to the jquery.min.js file. I can't tell why these three columns are having problems, since the data within them is pretty standard (just words, never blank). It seems to just keep sorting by whichever column was last successfully sorted.

Here is the code:

User clicks on "Go" Button - sends ajax query request to another page, which populates the results.

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"));
        }
    });
}

Table

<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>

I'm using version 2 of sorttable.js, Firefox 13.0.1, jquery v1.7.2

Generated 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>

Example of one of the tr's. They all follow this format, and the columns in question will always have data.

<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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM