当前位置:网站首页>In the case of easyUI DataGrid paging, click the small triangle icon in the header to reorder all the data in the database
In the case of easyUI DataGrid paging, click the small triangle icon in the header to reorder all the data in the database
2022-07-04 09:34:00 【Dandelion_ drq】
Explain :
When you click datagrid
When the small triangle icon of a column in the header ,easyui
It's sort of , But when we talk about datagrid
In the case of paging , Click Sort to sort the data on the current page , And the demand requires me to sort all the data in the database , In this case, you can only arrange the order from the background and then return .
Took a look at the documentation , It is found that clicking the small triangle icon will trigger onSortColumn
event , So we just need to ask the background again when this event is triggered datagrid
The data is ready .
Then go straight to the code ~~
var sortOrder = "asc"; // sort order ,asc: positive sequence ,desc: In reverse order
var sortField = "NickName"; // Name of the column to sort
// Initialize data list
function initDatagrid() {
$('#dg').datagrid({
url: '/api/Member',
method: "get",
striped: true,
border: true,
selectOnCheck: false,
checkOnSelect: false,
remoteSort: true, // Define whether to sort data from the server , To set up for true
singleSelect: false,
idField: 'MemberId',
pagination: true,
rownumbers: false,
pageSize: 20,
fitColumns: true,
columns: [[
...
]],
// Match the name of the column to be sorted with the positive order / These two parameters in reverse order are also transferred to the background for processing
onBeforeLoad: function (params) {
params.nickName = $("#nickName").val();
params.phone = $('#phone').val();
params.sortField = sortField;
params.sortOrder = sortOrder;
},
// The event triggered when clicking a column to sort
onSortColumn: function (sort, order) {
sortField = sort; // Name of the column to sort
sortOrder = order; // positive sequence or In reverse order
$('#dg').datagrid('reload');
}
});
}
But this is not perfect , stay easyui
In the original Click onSortColumn
Is to request a backstage , This point can be interrupted to test .
therefore , We need to block the original request , Otherwise, the background will be requested twice .
Specific measures , Is to modify jquery.easyui.js
/ jquery.easyui.min.js
file .
stay jquery.easyui.js
/ jquery.easyui.min.js
Search through the documents remoteSort
, Find the following code
if(opts.remoteSort){
_646(_63c);
}else{
_647(_63c,$(_63c).datagrid("getData"));
}
opts.onSortColumn.call(_63c,opts.sortName,opts.sortOrder);
};
hold if
Just comment out the code executed inside .( In the picture above is _646(_63c);
, It may be different ??).
PS:datagrid
and treegrid
There are remoteSort
This east east , Don't get me wrong !!
End.
边栏推荐
- Reload CUDA and cudnn (for tensorflow and pytorch) [personal sorting summary]
- 2022-2028 global industry research and trend analysis report on anterior segment and fundus OTC detectors
- 2022-2028 global small batch batch batch furnace industry research and trend analysis report
- pcl::fromROSMsg报警告Failed to find match for field ‘intensity‘.
- You can see the employment prospects of PMP project management
- MySQL foundation 02 - installing MySQL in non docker version
- If you can quickly generate a dictionary from two lists
- Launpad | basic knowledge
- Reading notes on how to connect the network - hubs, routers and routers (III)
- HMS core helps baby bus show high-quality children's digital content to global developers
猜你喜欢
The child container margin top acts on the parent container
Ultimate bug finding method - two points
Daughter love: frequency spectrum analysis of a piece of music
2022-2028 global intelligent interactive tablet industry research and trend analysis report
2022-2028 global gasket metal plate heat exchanger industry research and trend analysis report
C语言-入门-基础-语法-数据类型(四)
Sword finger offer 30 contains the stack of Min function
2022-2028 global industrial gasket plate heat exchanger industry research and trend analysis report
Mac platform forgets the root password of MySQL
PHP book borrowing management system, with complete functions, supports user foreground management and background management, and supports the latest version of PHP 7 x. Database mysql
随机推荐
What is uid? What is auth? What is a verifier?
如何编写单元测试用例
Write a jison parser (7/10) from scratch: the iterative development process of the parser generator 'parser generator'
20220701 barbarat lemma proof
The 14th five year plan and investment risk analysis report of China's hydrogen fluoride industry 2022 ~ 2028
什么是uid?什么是Auth?什么是验证器?
PHP is used to add, modify and delete movie information, which is divided into foreground management and background management. Foreground users can browse information and post messages, and backgroun
C语言-入门-基础-语法-[运算符,类型转换](六)
Launchpad x | mode
Write a jison parser from scratch (3/10): a good beginning is half the success -- "politics" (Aristotle)
C语言-入门-基础-语法-数据类型(四)
Research Report on the current market situation and development prospects of calcium sulfate whiskers in China (2022 Edition)
2022-2028 global elastic strain sensor industry research and trend analysis report
About the for range traversal operation in channel in golang
"How to connect the network" reading notes - Web server request and response (4)
Write a jison parser from scratch (2/10): learn the correct posture of the parser generator parser generator
At the age of 30, I changed to Hongmeng with a high salary because I did these three things
Analysis report on the development status and investment planning of China's modular power supply industry Ⓠ 2022 ~ 2028
Write a jison parser from scratch (6/10): parse, not define syntax
Opencv environment construction (I)