Jquery 需要对一个表进行排序,获取url并与其他人共享,以显示排序结果
我有一个表,我正在使用jquery.tablesorter.combined.js和saveSort小部件对多个列进行排序(使用shift+单击) 保存排序 是否有任何方法可以在服务器端对此进行排序并获取url,以便我可以复制和粘贴url,并通过url与其他人共享此结果? 加载这个URL应该会让我看到已排序的表的原样 请让我知道Jquery 需要对一个表进行排序,获取url并与其他人共享,以显示排序结果,jquery,widget,tablesorter,Jquery,Widget,Tablesorter,我有一个表,我正在使用jquery.tablesorter.combined.js和saveSort小部件对多个列进行排序(使用shift+单击) 保存排序 是否有任何方法可以在服务器端对此进行排序并获取url,以便我可以复制和粘贴url,并通过url与其他人共享此结果? 加载这个URL应该会让我看到已排序的表的原样 请让我知道 提前感谢我制作了一个小部件,将当前排序添加到哈希中。由于无法在内部框架上设置散列,因此它尚未经过彻底测试,并且似乎无法正常工作。它在一个完整的页面演示中工作 /*! W
提前感谢我制作了一个小部件,将当前排序添加到哈希中。由于无法在内部框架上设置散列,因此它尚未经过彻底测试,并且似乎无法正常工作。它在一个完整的页面演示中工作
/*! Widget: sort2Hash */
;( function( $ ) {
'use strict';
var ts = $.tablesorter || {},
s2h = {
init : function( c, wo ) {
var arry, indx, len, column, direction,
sort = s2h.getSort( c, wo );
if (sort) {
arry = sort.split( wo.sort2Hash_separator );
len = arry.length;
sort = [];
for ( indx = 0; indx < len; indx++ ) {
column = arry[ indx++ ];
direction = arry[ indx ];
if ( typeof direction !== 'undefined' ) {
sort.push( [ column, direction ] );
}
}
if ( sort.length ) {
c.sortList = sort;
}
}
c.$table.on( 'sortEnd.sort2hash', function() {
s2h.setHash( c, wo );
});
},
getTableId : function( c, wo ) {
return wo.sort2Hash_tableId ||
c.table.id ||
'table' + $( 'table' ).index( c.$table );
},
getSort : function( c, wo, clean ) {
// modified original code from http://www.netlobo.com/url_query_string_javascript.html
var name = s2h.getTableId( c, wo ).replace( /[\[]/, '\\[' ).replace( /[\]]/, '\\]' ),
sort = ( new RegExp( '[\\#&]' + name + '=([^&]*)' ) ).exec( window.location.hash );
if ( sort === null ) {
return '';
} else {
if ( clean ) {
window.location.hash = window.location.hash.replace( '&' + name + '=' + sort[ 1 ], '' );
}
return sort[ 1 ];
}
},
setHash : function( c, wo ) {
var hash, indx,
arry = [],
tableId = s2h.getTableId( c, wo ) + '=',
sort = c.sortList || [],
len = sort.length;
if ( len ) {
s2h.getSort( c, wo, true ); // remove hash
window.location.hash += ( window.location.hash.length ? '' : wo.sort2Hash_hash ) +
'&' + tableId +
// flatten array, then join with separator
[].concat.apply( [], sort ).join( wo.sort2Hash_separator );
}
}
};
ts.addWidget({
id: 'sort2Hash',
options: {
sort2Hash_hash : '#', // hash prefix
sort2Hash_separator : '-', // don't '#' or '=' here
sort2Hash_tableId : null // this option > table ID > table index on page
},
init: function(table, thisWidget, c, wo) {
s2h.init( c, wo );
},
remove: function(table, c) {
c.$table.off( 'sortEnd.sort2hash' );
}
});
})(jQuery);
$(function() {
$( 'table' ).tablesorter({
theme: 'blue',
widgets: [ 'zebra', 'sort2Hash' ],
widgetOptions : {
// hash prefix
sort2Hash_hash : '#',
// don't '#' or '=' here
sort2Hash_separator : ',',
// this option > table ID > table index on page
sort2Hash_tableId : null
}
});
});
/*!小部件:sort2Hash*/
;(函数($){
"严格使用",;
var ts=$.tablesorter |{},
s2h={
初始化:函数(c,wo){
变量arry、indx、len、column、direction、,
sort=s2h.getSort(c,wo);
如果(排序){
arry=排序.拆分(wo.sort2Hash\U分隔符);
len=棱长;
排序=[];
对于(indx=0;indx表ID>第页上的表索引
},
init:函数(表,thisWidget,c,wo){
s2h.初始(c,wo);
},
删除:功能(表c){
c、 $table.off('sortEnd.sort2hash');
}
});
})(jQuery);
$(函数(){
$(“表”).tablesorter({
主题:"蓝色",,
小部件:['zebra','sort2Hash'],
widgetOptions:{
//哈希前缀
sort2Hash_hash:“#”,
//不要在这里使用“#”或“=”
sort2Hash_分隔符:',',
//此选项>表ID>第页上的表索引
sort2Hash_tableId:null
}
});
});
我将在我的下一次更新中包含此小部件。我最后制作了一个小部件,将当前排序添加到哈希中。由于无法在内部框架上设置散列,因此它尚未经过彻底测试,并且似乎无法正常工作。它在一个完整的页面演示中工作
/*! Widget: sort2Hash */
;( function( $ ) {
'use strict';
var ts = $.tablesorter || {},
s2h = {
init : function( c, wo ) {
var arry, indx, len, column, direction,
sort = s2h.getSort( c, wo );
if (sort) {
arry = sort.split( wo.sort2Hash_separator );
len = arry.length;
sort = [];
for ( indx = 0; indx < len; indx++ ) {
column = arry[ indx++ ];
direction = arry[ indx ];
if ( typeof direction !== 'undefined' ) {
sort.push( [ column, direction ] );
}
}
if ( sort.length ) {
c.sortList = sort;
}
}
c.$table.on( 'sortEnd.sort2hash', function() {
s2h.setHash( c, wo );
});
},
getTableId : function( c, wo ) {
return wo.sort2Hash_tableId ||
c.table.id ||
'table' + $( 'table' ).index( c.$table );
},
getSort : function( c, wo, clean ) {
// modified original code from http://www.netlobo.com/url_query_string_javascript.html
var name = s2h.getTableId( c, wo ).replace( /[\[]/, '\\[' ).replace( /[\]]/, '\\]' ),
sort = ( new RegExp( '[\\#&]' + name + '=([^&]*)' ) ).exec( window.location.hash );
if ( sort === null ) {
return '';
} else {
if ( clean ) {
window.location.hash = window.location.hash.replace( '&' + name + '=' + sort[ 1 ], '' );
}
return sort[ 1 ];
}
},
setHash : function( c, wo ) {
var hash, indx,
arry = [],
tableId = s2h.getTableId( c, wo ) + '=',
sort = c.sortList || [],
len = sort.length;
if ( len ) {
s2h.getSort( c, wo, true ); // remove hash
window.location.hash += ( window.location.hash.length ? '' : wo.sort2Hash_hash ) +
'&' + tableId +
// flatten array, then join with separator
[].concat.apply( [], sort ).join( wo.sort2Hash_separator );
}
}
};
ts.addWidget({
id: 'sort2Hash',
options: {
sort2Hash_hash : '#', // hash prefix
sort2Hash_separator : '-', // don't '#' or '=' here
sort2Hash_tableId : null // this option > table ID > table index on page
},
init: function(table, thisWidget, c, wo) {
s2h.init( c, wo );
},
remove: function(table, c) {
c.$table.off( 'sortEnd.sort2hash' );
}
});
})(jQuery);
$(function() {
$( 'table' ).tablesorter({
theme: 'blue',
widgets: [ 'zebra', 'sort2Hash' ],
widgetOptions : {
// hash prefix
sort2Hash_hash : '#',
// don't '#' or '=' here
sort2Hash_separator : ',',
// this option > table ID > table index on page
sort2Hash_tableId : null
}
});
});
/*!小部件:sort2Hash*/
;(函数($){
"严格使用",;
var ts=$.tablesorter |{},
s2h={
初始化:函数(c,wo){
变量arry、indx、len、column、direction、,
sort=s2h.getSort(c,wo);
如果(排序){
arry=排序.拆分(wo.sort2Hash\U分隔符);
len=棱长;
排序=[];
对于(indx=0;indx