Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Tablesorter 2.0插件和带有嵌套HTML的表_Javascript_Asp.net Mvc_Sorting_Html Table_Tablesorter - Fatal编程技术网

Javascript Tablesorter 2.0插件和带有嵌套HTML的表

Javascript Tablesorter 2.0插件和带有嵌套HTML的表,javascript,asp.net-mvc,sorting,html-table,tablesorter,Javascript,Asp.net Mvc,Sorting,Html Table,Tablesorter,我使用的是来自的Tablesorter插件,在MVC Razor视图中有下表 @foreach (var item in Model.Products) { decimal? vatValue = (item.UnitPrice * item.Quantity) * 0.2M; decimal? goodsValue = (item.UnitPrice * item.Quantity); <tr> <td class="product-t

我使用的是来自的Tablesorter插件,在MVC Razor视图中有下表

@foreach (var item in Model.Products)
{
    decimal? vatValue = (item.UnitPrice * item.Quantity) * 0.2M;
    decimal? goodsValue = (item.UnitPrice * item.Quantity);
    <tr>
        <td class="product-title" data-thumbnail="/_includes/img/uploads/product-thumb.jpg"><span>@item.ProductName</span>
        </td>
        <td class="product-id">
            <span class="hl">Product code: </span>
            @item.ProductCode
        </td>
        <td class="price">&pound;@item.UnitPrice 
            <small class="hl">unit price</small>
        </td>
        <td class="units">
            <input type="number" class="choose-quantity" placeholder="0" value="@item.Quantity" min="0" readonly="readonly">
        </td>
        <td class="vat">
            <small class="hl">VAT:</small>
            &pound;@(vatValue)
        </td>
        <td class="goods-value">
            <small class="hl">Goods value:</small>
            &pound;@(goodsValue)
        </td>
    </tr>
}
@foreach(Model.Products中的变量项)
{
十进制?VAT值=(项目.单价*项目.数量)*0.2M;
十进制?商品价值=(item.UnitPrice*item.Quantity);
@item.ProductName
产品代码:
@item.ProductCode
&英镑;@item.UnitPrice
单价
大桶:
&英镑;@(价值)
货物价值:
&英镑;@(货物价值)
}
增值税列和货物价值列不包含数字。我理解为什么会这样,这是因为我们有一个嵌套的标记,它被排序在上面,插件很可能会将HTML解释为字符串的一部分来排序,因此不会进行数字排序

有什么我可以解决的吗?我可以在此表上设置任何配置设置,使其仅查找数字


谢谢

如果将值包装在一个范围内,可能最简单:

<tr>
    <td class="product-title" data-thumbnail="/_includes/img/uploads/product-thumb.jpg">
        <span>@item.ProductName</span>
    </td>
    <td class="product-id">
        <span class="hl">Product code: </span>
        @item.ProductCode
    </td>
    <td class="price">
        <span>&pound;@item.UnitPrice</span>
        <small class="hl">unit price</small>
    </td>
    <td class="units">
        <input type="number" class="choose-quantity" placeholder="0" value="@item.Quantity" min="0" readonly="readonly">
    </td>
    <td class="vat">
        <small class="hl">VAT:</small>
        <span>&pound;@(vatValue)</span>
    </td>
    <td class="goods-value">
        <small class="hl">Goods value:</small>
        <span>&pound;@(goodsValue)</span>
    </td>
</tr>

*注*用于列目标的类名必须与
字段
中单元格的类名相匹配,而不是与
正文
中单元格的类名相匹配。如果将值包装在span中,可能最简单:

<tr>
    <td class="product-title" data-thumbnail="/_includes/img/uploads/product-thumb.jpg">
        <span>@item.ProductName</span>
    </td>
    <td class="product-id">
        <span class="hl">Product code: </span>
        @item.ProductCode
    </td>
    <td class="price">
        <span>&pound;@item.UnitPrice</span>
        <small class="hl">unit price</small>
    </td>
    <td class="units">
        <input type="number" class="choose-quantity" placeholder="0" value="@item.Quantity" min="0" readonly="readonly">
    </td>
    <td class="vat">
        <small class="hl">VAT:</small>
        <span>&pound;@(vatValue)</span>
    </td>
    <td class="goods-value">
        <small class="hl">Goods value:</small>
        <span>&pound;@(goodsValue)</span>
    </td>
</tr>

*注*用于列目标的类名必须与
字段中单元格的类名相匹配,而不是
tbody

中的单元格。事实上,这与我所做的非常相似。我遇到了这个问题和另一个问题,由于£;字符代码。我在每个字段中都写了一个隐藏跨距,并将其放在第一位。在表中看不到它,但允许有效地进行搜索。我还要说,你的插件做得很棒!非常有帮助,继续做好工作,谢谢!事实上,这与我所做的非常相似。我遇到了这个问题和另一个问题,由于£;字符代码。我在每个字段中都写了一个隐藏跨距,并将其放在第一位。在表中看不到它,但允许有效地进行搜索。我还要说,你的插件做得很棒!非常有帮助,继续做好工作,谢谢!