如何保存使用 angularjs 创建的表的排序顺序?

问题描述

我使用 angularjs 创建了一个带有可排序列的表,代码如下(注意表中的数据是提交列表):

<p-table #tt [columns]="cols" [value]="shownSubmissions" [paginator]="true" [rows]="rowCount"
    [resizableColumns]="true" [rowHover]="true" styleClass="primeng-custom">
    <ng-template pTemplate="caption">
      <div class="ui-helper-clearfix">
        <span style="float:left;margin-top:2px;">Show
          <p-dropdown [options]="entries" optionLabel="val" (onChange)="updateRowCount($event)" placeholder="50">
          </p-dropdown>
          entries</span>
        <span style="float:right">
          <i class="fa fa-search" style="margin:4px 4px 0 0"></i>
          <input type="text" pInputText size="25" placeholder="Search"
            (input)="tt.filterGlobal($event.target.value,'contains')" style="width:auto; display:inline-block;"
            class="form-control">
        </span>
      </div>
    </ng-template>

    <ng-template pTemplate="header" let-columns>
      <tr>
        <th style="text-align:center;" [ngStyle]="{'width':col.width}" *ngFor="let col of columns"
          [pSortableColumn]="col.field" pResizableColumn>
          {{col.header}}
          <p-sortIcon [field]="col.field"></p-sortIcon>
        </th>
        <th style="text-align:center">Action</th>
      </tr>
    </ng-template>

    <ng-template pTemplate="body" let-sub let-columns="columns">
      <tr>
        <td *ngFor="let col of columns" style="overflow: hidden; word-wrap: break-word">
          {{col.isDate ? (sub[col.field] | date:'MM/dd/yy') : sub[col.field]}}
        </td>
        <td>
          <a class="block" [routerLink]="['/viewsubmission',sub.submissionId]">View</a>
          <a class="block" *ngIf="sub.canEdit" [routerLink]="['/editsubmission',sub.submissionId]">Edit</a>
        </td>
      </tr>
    </ng-template>
  </p-table>

我希望能够对表格中的一列应用排序,移动到我网站的其他部分,然后在保留列排序的情况下返回表格。我该怎么做?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...