How to use layui to get the value of the selected row in the table
In layui, the method of getting the value of the selected row in the table is as follows:
1. Get the current All selected rows
layui.table.checkStatus('tableId');
2. Get the currently selected row data
let data = layui.table.checkStatus('tableId').data;
3. Get the currently selected row index
let index = layui.table.checkStatus('tableId').index;
Among them, tableId is the container ID of the table.
Sample code:
layui.use('table', function () { var table = layui.table; // 获取表格实例 let instance = table.render({ elem: '#test-table', data: [{ id: 1, name: 'John Doe' }, { id: 2, name: 'Jane Doe' }], cols: [[{ type: 'checkbox' }, { field: 'id', title: 'ID' }, { field: 'name', title: '姓名' }]] }); // 获取当前选中的行 let data = table.checkStatus('test-table').data; // 输出选中行的姓名 console.log(data[0].name); // John Doe });
The above is the detailed content of How to get the selected row value of table table in layui. For more information, please follow other related articles on the PHP Chinese website!

The article discusses using Layui's flow module for infinite scrolling, covering setup, best practices, performance optimization, and customization for enhanced user experience.

The article details how to use Layui's element module to create and customize UI elements like tabs, accordions, and progress bars, highlighting HTML structures, initialization, and common pitfalls to avoid.Character count: 159

The article discusses customizing Layui's carousel module, focusing on CSS and JavaScript modifications for appearance and behavior, including transition effects, autoplay settings, and adding custom navigation controls.

The article guides on using Layui's carousel module for image sliders, detailing steps for setup, customization options, implementing autoplay and navigation, and performance optimization strategies.

The article discusses configuring Layui's upload module to restrict file types and sizes using accept, exts, and size properties, and customizing error messages for violations.

The article explains how to use Layui's layer module to create modal windows and dialog boxes, detailing setup, types, customization, and common pitfalls to avoid.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Atom editor mac version download
The most popular open source editor

Dreamweaver CS6
Visual web development tools

Dreamweaver Mac version
Visual web development tools