Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to move up and down with layui and JQuery

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "layui plus JQuery how to move up and down", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "layui plus JQuery how to move up and down" article.

Idea: it is to reorder the checked data (mainly the unique ID and its data relocation) and set the sequence number in the background. Only radio codes are supported how to:

* / / first step * *

Var data_tr

/ / trigger radio box selection

Table.on ('radio ()', function (obj) {/ / test is the lay-filter attribute corresponding to the table tag

Data_tr = $(this)

});

* / / move up * *

Function uptr () {

/ / get the list collection

Var datas = layui.table.cache ["list"]

/ / get the selected data

Var checkStatus = table.checkStatus ('list'), data = checkStatus.data

If (typeof (data [0]) = = "undefined") {

Layer.msg ("Please select a data to move")

} else {

Var tr = $(data_tr). Parent (). Parent (). Parent ()

Debugger

If ($(tr) .prev () .html () = = null) {

Layer.msg ("already at the top")

Return

} else {

/ / record the data of this line and the next line before moving up

Var tem = datas [tr.index ()]

Var tem2 = datas [tr.prev () .index ()]

/ / insert yourself before the target tr

$(tr) .insertBefore ($(tr) .prev ())

/ / after moving up, data exchange

Datas [tr.index ()] = tem

Datas [tr.next () .index ()] = tem2

}

}

}

* / move up to the top * *

Function upTop () {

Var datas = layui.table.cache ["list"]

Var checkStatus = table.checkStatus ('list'), data = checkStatus.data

If (typeof (data [0]) = = "undefined") {

Layer.msg ("Please select a data to move")

} else {

Var tr = $(data_tr). Parent (). Parent (). Parent ()

If ($(tr) .prev () .html () = = null) {

Layer.msg ("already at the top")

Return

} else {

/ / render the data to the first one

(tr) .insertBefore ($(tr) .siblings (": first"))

/ / Delete the selected data $(tr) .attr ("data-index") to get the serial number of the selected data

Datas.splice ($(tr) .attr ("data-index"), 1)

/ / the front insert in the array

Datas.unshift (data [0])

}

}

}

* / / move down * *

Function downtr () {

Var datas = layui.table.cache ["list"]

Var checkStatus = table.checkStatus ('list'), data = checkStatus.data

If (typeof (data [0]) = = "undefined") {

Layer.msg ("Please select a data to move")

} else {

Var tr = $(data_tr). Parent (). Parent (). Parent ()

Debugger

If ($(tr) .next () .html () = = null) {

Layer.msg ("it's already the bottom")

Return

} else {

/ / record the data of this line and the next line

Var tem = datas [tr.index ()]

Var tem2 = datas [tr.next () .index ()]

/ / insert yourself after the target tr

$(tr) .insertAfter ($(tr) .next ())

/ / Exchange data

Datas [tr.index ()] = tem

Datas [tr.prev () .index ()] = tem2

}

}

}

* / / move down to the bottom * *

Function downBottom () {

Var datas = layui.table.cache ["list"]

Var checkStatus = table.checkStatus ('list'), data = checkStatus.data

Debugger

If (typeof (data [0]) = = "undefined") {

Layer.msg ("Please select a data to move")

} else {

Var tr = $(data_tr). Parent (). Parent (). Parent ()

Debugger

If ($(tr) .next () .html () = = null) {

Layer.msg ("it's already the bottom")

Return

} else {

/ / render the data to the last entry

(tr) .insertAfter ($(tr) .siblings (": last"))

Datas.splice ($(tr) .attr ("data-index"), 1)

/ / add sequentially at the end of the array

Datas.push (data [0])

}

}

}

* * / / finally call the modified API * *

Function updateSortData () {

Debugger

Var instanceGUIDs = ""

Var data = layui.table.cache ["list"]

If (data.length > 1) {

For (var I = 0; I < data.length; iTunes +) {

InstanceGUIDs + = Data [I] .instanceGUID + ","

}

}

$.post ("/ spring/office/todo/saveTodoSort", {

Ids: instanceGUIDs

UserGUID: userGUID

}, function (data) {

If (data) {

$.newuiAlert ('sorting successful!')

/ / tableInit ()

} else {

$.newuiAlert ('sort failed!')

}

});

* * / / implementation * *

@ Autowired

Private JdbcTemplate jdbcTemplate

@ RequestMapping ("/ saveTodoSort")

Public @ ResponseBody boolean saveTodoSort (HttpServletRequest request) {

String userGUID = request.getParameter ("userGUID")

String ids = request.getParameter ("ids")

Boolean isSuccess = false

Try {

If (StringUtils.isNotBlank (userGUID) & & StringUtils.isNotBlank (ids)) {

String [] instanceGUIDs = ids.split (",")

List batchParams = new ArrayList (instanceGUIDs.length)

String sql = "update OFFICE_WorkflowInstanceActors set STAR_LEVEL=? where WORKFLOWINSTANCE_GUID=? and PERSON_GUID=? and ACTORS_CLASSIFY=?"

For (int I = 0; I < instanceGUIDs.length; iTunes +) {

BatchParams.add (new Object [] {(instanceGUIDs.length-I), instanceGUIDs [I], userGUID, 1})

}

JdbcTemplate.batchUpdate (sql, batchParams)

IsSuccess = true

}

} catch (Exception ex) {

Ex.printStackTrace ()

}

Return isSuccess

}

The above is the content of this article on "how to move up and down with layui and JQuery". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report