Implementation method of deleting the current row in layui data table

藏色散人
Release: 2020-11-30 13:57:34
Original
4237 people have browsed it

How to delete the current row in layui data table: first create a code sample file; then delete the current row through the "oldData.splice(obj.tr.data('index'),1);" method That’s it.

Implementation method of deleting the current row in layui data table

Recommended: "layUI Tutorial"

The operating environment of this tutorial: windows10 system, layui2.5.6 version, the The method is applicable to all brands of computers.

The data table is as follows:

t2 = { elem: '#test2', data: tableData2, page: false, width: $(parent.window).width()-50, cols: [[ {type:'checkbox',field:'id'}, {field:'cstMoldNo', title: '客户模号',edit:'text'}, {field:'cstProdName', title: '产品名称',edit:'text'}, {field:'material', title: '产品材料',edit:'text'}, {field:'firstTryDate', title: '验证日期',edit:'text'}, {field:'deliveryDate', title: '交货日期',edit:'text'}, {field:'unit', title: '单位',edit:'text'}, {field:'count', title: '数量',edit:'text'}, {field:'upTax', title: '含税单价',edit:'text'}, {field:'priceTax', title: '含税金额',edit:'text'}, {field:'remark', title: '备注',edit:'text'}, {fixed: 'right', title: '操作',width: '10%',align: 'center',toolbar: '#barDemo'} ]] };
Copy after login

Click to delete the current row:

if(obj.event === "del"){ layer.confirm("你确定要删除么?",{btn:['是的,我确定','我再想想']}, function(){ var oldData = table.cache["test2"]; oldData.splice(obj.tr.data('index'),1); layer.msg("删除成功",{time: 10},function(){ table.reload('test2',{data : oldData}); }); } ) }
Copy after login

The splice() method is mainly used to delete the current row of the table in layui,

The splice() method adds/removes items to/from an array and returns the removed item.

Note: This method will change the original array.

Syntax

arrayObject.splice(index,howmany,item1,.....,itemX)
Copy after login

Implementation method of deleting the current row in layui data table

Description

The splice() method can delete zero or more elements starting from index and use Replaces the deleted elements with one or more values declared in the argument list.

The above is the detailed content of Implementation method of deleting the current row in layui data table. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!