当前位置:网站首页>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.
边栏推荐
- 什么是权限?什么是角色?什么是用户?
- Launpad | 基礎知識
- How does idea withdraw code from remote push
- How do microservices aggregate API documents? This wave of show~
- Global and Chinese markets of thrombography hemostasis analyzer (TEG) 2022-2028: Research Report on technology, participants, trends, market size and share
- Global and Chinese market of sampler 2022-2028: Research Report on technology, participants, trends, market size and share
- HMS core helps baby bus show high-quality children's digital content to global developers
- Lauchpad x | MODE
- Report on research and investment prospect prediction of China's electronic grade sulfuric acid industry (2022 Edition)
- 【leetcode】540. A single element in an ordered array
猜你喜欢

【LeetCode 42】501. Mode in binary search tree

Mantis creates users without password options

mmclassification 标注文件生成

Latex download installation record

pcl::fromROSMsg报警告Failed to find match for field ‘intensity‘.

保姆级JDEC增删改查练习

2022-2028 global edible probiotic raw material industry research and trend analysis report

2022-2028 global probiotics industry research and trend analysis report

Nurse level JDEC addition, deletion, modification and inspection exercise

MySQL foundation 02 - installing MySQL in non docker version
随机推荐
Leetcode (Sword finger offer) - 35 Replication of complex linked list
Development trend and market demand analysis report of high purity tin chloride in the world and China Ⓔ 2022 ~ 2027
Lauchpad X | 模式
Global and Chinese market of wheel hubs 2022-2028: Research Report on technology, participants, trends, market size and share
Flutter tips: various fancy nesting of listview and pageview
Report on research and investment prospects of polyglycolic acid industry in China (2022 Edition)
How should PMP learning ideas be realized?
What is permission? What is a role? What are users?
2022-2028 global gasket metal plate heat exchanger industry research and trend analysis report
Jianzhi offer 09 realizes queue with two stacks
Research Report on the current market situation and development prospects of calcium sulfate whiskers in China (2022 Edition)
Write a jison parser from scratch (5/10): a brief introduction to the working principle of jison parser syntax
【leetcode】29. Divide two numbers
SSM online examination system source code, database using mysql, online examination system, fully functional, randomly generated question bank, supporting a variety of question types, students, teache
【LeetCode 42】501. Mode in binary search tree
"How to connect the network" reading notes - Web server request and response (4)
Implementation principle of redis string and sorted set
The child container margin top acts on the parent container
保姆级JDEC增删改查练习
AMLOGIC gsensor debugging