This js code was written by someone else, and it may not be the best, but I personally think it would be particularly good if it can help others solve functional problems first. I modified it slightly and used it in my own project. I will post it here to share it. The TinkPHP used in the backend is relatively simple to check for additions, deletions and modifications, so I won’t post it here. I won’t post the front desk renderings because I’m lazy.
$(function () {var datagrid; //定义全局变量datagridvar editRow = undefined; //定义全局变量:当前编辑的行datagrid = TskupluAddPacket.datagrid({ url: ThinkPHP['MODULE'] + '/Tskuplu/getPacketList', //请求的数据源iconCls: 'icon-save', //图标pagination: true, //显示分页pageSize: 15, //页大小pageList: [15, 30, 45, 60], //页大小下拉选项此项各value是pageSize的倍数fit: true, //datagrid自适应宽度fitColumn: false, //列自适应宽度striped: true, //行背景交换nowap: true, //列内容多时自动折至第二行border: false, idField: 'packetid', //主键sortName : 'packetid', //排序字段sortOrder : 'desc', //排序方式columns: [[//显示的列{field: 'packetid', title: 'ID', width: 100, sortable: true, checkbox: true }, { field: 'packunit', title: '包装单位', width: 100, sortable: true, editor: { type: 'validatebox', options: { required: true} } }, { field: 'packqty', title: '包装细数', width: 100, editor: { type: 'validatebox', options: { required: true} } }, { field: 'packspec', title: '包装规格', width: 100, editor: { type: 'validatebox', options: { required: true} } } ]], queryParams: { pluid: $('#addpluid').val() }, //查询参数toolbar: [{ text: '添加', iconCls: 'icon-add', handler: function () {//添加列表的操作按钮添加,修改,删除等//添加时如果没有正在编辑的行,则在datagrid的第一行插入一行if (editRow == undefined) { datagrid.datagrid("insertRow", { index: 0, // index start with 0 row: {} }); //将新插入的那一行开户编辑状态datagrid.datagrid("beginEdit", 0);//给当前编辑的行赋值editRow = 0; } } }, '-', { text: '删除', iconCls: 'icon-remove', handler: function () { //删除时先获取选择行 var rows = datagrid.datagrid("getSelections"); //选择要删除的行 if (rows.length > 0) { $.messager.confirm("提示", "你确定要删除吗?", function (r) {if (r) {var ids = [];for (var i = 0; i 0){ datagrid.datagrid('reload'); $.messager.show({ title : '操作提醒', msg : data + '条数据被成功删除!'}) } else if( data == -999 ) { $.messager.alert('删除失败', '对不起,您没有权限!', 'warning'); } else { $.messager.alert('删除失败', '没有删除任何数据!', 'warning'); } } }); } }); } else { $.messager.alert("提示", "请选择要删除的行", "error"); } } }, '-', { text: '修改', iconCls: 'icon-edit', handler: function () {//修改时要获取选择到的行var rows = datagrid.datagrid("getSelections");//如果只选择了一行则可以进行修改,否则不操作if (rows.length == 1) {//当无编辑行时if (editRow == undefined) {//获取到当前选择行的下标var index = datagrid.datagrid("getRowIndex", rows[0]);//开启编辑datagrid.datagrid("beginEdit", index);//把当前开启编辑的行赋值给全局变量editRoweditRow = index;//当开启了当前选择行的编辑状态之后,//应该取消当前列表的所有选择行,要不然双击之后无法再选择其他行进行编辑datagrid.datagrid("unselectAll"); } } } }, '-', { text: '保存', iconCls: 'icon-save', handler: function () { //保存时结束当前编辑的行,自动触发onAfterEdit事件如果要与后台交互可将数据通过Ajax提交后台 datagrid.datagrid("endEdit", editRow); editRow = undefined; } }, '-', { text: '取消编辑', iconCls: 'icon-redo', handler: function () { //取消当前编辑行把当前编辑行罢undefined回滚改变的数据,取消选择的行 editRow = undefined; datagrid.datagrid("rejectChanges"); datagrid.datagrid("unselectAll"); } }, '-'], onAfterEdit: function (rowIndex, rowData, changes) {//endEdit该方法触发此事件 //var row = datagrid.datagrid("getData").rows[rowIndex]; //获取某一行的值 var inserted = datagrid.datagrid('getChanges','inserted');var updated = datagrid.datagrid('getChanges','updated');if(inserted.length 0){ url=ThinkPHP['MODULE'] + '/Tskuplu/addPacket'; }if(updated.length>0){ url=ThinkPHP['MODULE'] + '/Tskuplu/updatePacket'; } $.ajax({ url : url, type : 'POST', data : { 'pluid': $('#addpluid').val(), 'packetid':rowData.packetid, 'packunit':rowData.packunit, 'packqty' :rowData.packqty, 'packspec':rowData.packspec }, beforeSend : function (){ $.messager.progress({ text : '正在处理中...' }) }, success : function (data){ $.messager.progress('close'); if (data > 0){ datagrid.datagrid("acceptChanges"); $.messager.show({ title : '操作提示', msg : '添加成功'}); editRow = undefined; datagrid.datagrid("reload"); $('#addcheck').val(1); } else if (data == -999) { $.messager.alert('添加失败', '抱歉!您没有权限!', 'warning'); } else { datagrid.datagrid("beginEdit",editRow); $.messager.alert('警告操作', '未知错误!请重新刷新后提交!', 'warning'); } datagrid.datagrid("unselectAll"); } });////////////////// }, onDblClickRow: function (rowIndex, rowData) {//双击开启编辑行if (editRow == undefined) { datagrid.datagrid("beginEdit", rowIndex); editRow = rowIndex; } } }); });
The above is the detailed content of Inline editing of EasyUI's dataGrid. For more information, please follow other related articles on the PHP Chinese website!

TomodifydatainaPHPsession,startthesessionwithsession_start(),thenuse$_SESSIONtoset,modify,orremovevariables.1)Startthesession.2)Setormodifysessionvariablesusing$_SESSION.3)Removevariableswithunset().4)Clearallvariableswithsession_unset().5)Destroythe

Arrays can be stored in PHP sessions. 1. Start the session and use session_start(). 2. Create an array and store it in $_SESSION. 3. Retrieve the array through $_SESSION. 4. Optimize session data to improve performance.

PHP session garbage collection is triggered through a probability mechanism to clean up expired session data. 1) Set the trigger probability and session life cycle in the configuration file; 2) You can use cron tasks to optimize high-load applications; 3) You need to balance the garbage collection frequency and performance to avoid data loss.

Tracking user session activities in PHP is implemented through session management. 1) Use session_start() to start the session. 2) Store and access data through the $_SESSION array. 3) Call session_destroy() to end the session. Session tracking is used for user behavior analysis, security monitoring, and performance optimization.

Using databases to store PHP session data can improve performance and scalability. 1) Configure MySQL to store session data: Set up the session processor in php.ini or PHP code. 2) Implement custom session processor: define open, close, read, write and other functions to interact with the database. 3) Optimization and best practices: Use indexing, caching, data compression and distributed storage to improve performance.

PHPsessionstrackuserdataacrossmultiplepagerequestsusingauniqueIDstoredinacookie.Here'showtomanagethemeffectively:1)Startasessionwithsession_start()andstoredatain$_SESSION.2)RegeneratethesessionIDafterloginwithsession_regenerate_id(true)topreventsessi

In PHP, iterating through session data can be achieved through the following steps: 1. Start the session using session_start(). 2. Iterate through foreach loop through all key-value pairs in the $_SESSION array. 3. When processing complex data structures, use is_array() or is_object() functions and use print_r() to output detailed information. 4. When optimizing traversal, paging can be used to avoid processing large amounts of data at one time. This will help you manage and use PHP session data more efficiently in your actual project.

The session realizes user authentication through the server-side state management mechanism. 1) Session creation and generation of unique IDs, 2) IDs are passed through cookies, 3) Server stores and accesses session data through IDs, 4) User authentication and status management are realized, improving application security and user experience.


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver CS6
Visual web development tools

SublimeText3 Chinese version
Chinese version, very easy to use

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
