Jquery tablesorter插件尝试禁用排序但不起作用

时间:2015-05-12 13:47:53

标签: javascript php jquery html tablesorter

所以我有一个表,我正在使用jQuery插件tablersorter(tablesorter.com)进行排序。我的表中有两个标题,我不想排序,我试图禁用。我使用了网站上提供的示例,但它似乎打破了排序,而不是让我排序。这是我目前的代码。

HTML

#import "SingleNewsViewController.h"

@interface SingleNewsViewController ()

@end

@implementation SingleNewsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSAttributedString *image = [self imageString];
    NSAttributedString *date = [self dateString];
    NSAttributedString *body = [self bodyString];

    NSMutableAttributedString *wholeStory = [NSMutableAttributedString new];

    // TODO: can you be sure image, date and body are all non-nil?
    NSArray *allComponents = @[image, date, body];
    for(NSAttributedString *component in allComponents)
    {
        [wholeStory appendAttributedString:component];
        if(component != [allComponents lastObject])
            [[wholeStory mutableString] appendString:@"\n\n"];
    }

    self.tv.attributedText = wholeStory;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (UIImage *)image
{
    return [UIImage imageNamed:@"latest_news_img.jpg"];
}

- (NSString *)dateText
{
    return @"Hi There, this is date!";
}

- (NSString *)bodyText
{
    return @"Hi There, this is body text!Hi There, .....";
}

- (NSAttributedString *)imageString
{
    NSTextAttachment *textAttachment = [[NSTextAttachment alloc] init];
    textAttachment.image = [self image];
    return [NSAttributedString attributedStringWithAttachment:textAttachment];
}

- (NSAttributedString *)dateString
{
    return [[NSAttributedString alloc]
            initWithString:[self dateText]
            /*attributes:
             @{
             NSFontAttributeName: [UIFont preferredFontForTextStyle: UIFontTextStyleSubheadline],
             ... etc ...
             }*/];
}

- (NSAttributedString *)bodyString
{
    return [[NSAttributedString alloc]
            initWithString:[self bodyText]
            /*attributes:
             @{
             NSFontAttributeName: [UIFont preferredFontForTextStyle: UIFontTextStyleBody],
             ... etc ...
             }*/];
}



@end

JAVASCRIPT

<table border="0" cellpadding="0" cellspacing="0" id="orgTable" class="tablesorter">
<thead>
<tr>
    <th><?=$languageDB->berkGet("object_organization_name");?></th>
    <th><?=$languageDB->berkGet("object_organization_description");?></th>
    <th><?=$languageDB->berkGet("object_organization_system_name");?></th>
    <th><?=$languageDB->berkGet("object_organization_status");?></th>
    <th><?=$languageDB->berkGet("object_organization_client");?></th>
    <th><?=$languageDB->berkGet("object_organization_actions");?></th>
</tr>
</thead>
<tbody>
<?foreach ($organizations as $organizationObj) {
    foreach ($organizationObj as $curOrg) {
        if($curOrg->get("name") == "System"){
            //Hide the System organization from vCloud 
            continue;
        }?> 
    <tr>
        <td><?=$curOrg->get("name");?></td>
        <td><?=$curOrg->get("description")===""?"None":$curOrg->get("description")?></td>
        <td><?=$curOrg->get("systemName")?></td>
        <td><?=$status[$curOrg->get('status')];?></td>
        <td id="client<?=$curOrg->get('id');?>">            
            <?if($curOrg->get("clientId")==0){ ?>
                <button class="btn btn-tiny btn-reverse associate" data-uid="<?=$curOrg->get('id');?>"><?=$languageDB->berkGet("action_associate");?></button>
            <?} else{ 
                $client=new client($curOrg->get("clientId"));?>
                <?=$client->get("companyName");?>
            <?}?>
        </td>
        <td><a href="/organizationDetails.php?id=<?=$curOrg->get('id');?>" class="btn btn-tiny"><i class="fa fa-info-circle"></i></a>
            <?if($curOrg->get("clientId")>0){ ?>
                <button class="btn btn-danger btn-tiny" id="remove" data-uid="<?=$curOrg->get('id');?>" data-name="<?=$curOrg->get('name');?>"><i class="fa fa-trash"></i> </button>
            <?}?>
    </tr>   
    <?}
}?>
</tbody>
</table>

1 个答案:

答案 0 :(得分:0)

我不知道这是否解决,但尝试添加缺少的标签。

<td><a href="/organizationDetails.php?id=<?=$curOrg->get('id');?>" class="btn btn-tiny"><i class="fa fa-info-circle"></i></a>
        <?if($curOrg->get("clientId")>0){ ?>
            <button class="btn btn-danger btn-tiny" id="remove" data-uid="<?=$curOrg->get('id');?>" data-name="<?=$curOrg->get('name');?>"><i class="fa fa-trash"></i> </button>
        <?}?> // dont forget to close </td>

也不要使用<?foreach... 而是使用<?php foreach...?