国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Web Front-end JS Tutorial jQuery LigerUI usage tutorial form (1)_jquery

jQuery LigerUI usage tutorial form (1)_jquery

May 16, 2016 pm 05:56 PM

The first example
Introduction
ligerGrid is the core control of the ligerui series of plug-ins. Users can quickly create a beautiful and powerful table that supports sorting, paging, multiple headers, fixed columns, etc.

Supports local data and server data (configuration data or url)
Supports sorting and paging (including Javascript sorting and paging)
Supports "show/hide" of columns
Supports multiple table headers
Support fixed columns
Support detail rows
Support summary rows
Support cell templates
Support table editing (three editing modes, cell editing, row editing, detail editing)
Support tree table
Support grouping
Code
First introduce basic css and js files

Copy code Code As follows:





Then you can use liger Grid
Copy the code The code is as follows:




Effect
Data structure
Table data structure
Table data has two attributes, one is Rows and the other is Total. Among them, Rows is a data array and Total is the total number of records.
In fact, Total does not need to provide it when using local data. The format we use local data can be like this:
Copy code The code is as follows:

{
Rows: [
{ id: '01', name: 'Department 01' },
{ id: '02', name: 'Department 02' },
{ id: '03', name: 'Department 03' },
{ id: '04', name: 'Department 04' },
{ id: '05', name: 'Department 05' },
{ id: '06', name: 'Department 06' },
{ id: '07', name: 'Department 07' }
]
}

id, name both It is a record attribute, which can be customized at will. When configuring columns, you do not have to configure the corresponding columns, you only need to configure the corresponding displayed columns. In subsequent operations, these properties can be obtained. For example, the method getSelected(). Custom cell function render.
Tree table data structure
The tree structure engineer adds a children parameter based on the table data, such as:
Copy code The code is as follows:

{
Rows: [
{ id: '01', name: 'Department 01', children: [
{ id : '0101', name: 'Department 0101' },
{ id: '0102', name: 'Department 0102' },
{ id: '0103', name: 'Department 0103' }
]
},
{ id: '02', name: 'Department 02' },
{ id: '03', name: 'Department 03' },
{ id: ' 04', name: 'Department 04' },
{ id: '05', name: 'Department 05' },
{ id: '06', name: 'Department 06' },
{ id: '07', name: 'Department 07' }
]
}

Two ways to bind data
ligerGrid has two ways to bind data, One is to use local data, and the other is to use server data.
In the first example, we configured the data parameter, this way is the local way. Another way is to configure url parameters and use remote data.

Configure column
How many columns are displayed in the table, column width, and the content to be displayed in the column cells are all configured by the columns attribute. The following are the configuration parameters of column:
Copy code The code is as follows:

{
display: 'serial number', //The text displayed in the header column, supports html
//Custom function for header content
headerRender: function (column) {
return "" column.display "";
},
name: 'id', //The row data attribute of cell mapping
align: 'center' , //Cell content alignment: left/center/right
hide: false, //Whether to hide
width: 100, //The width of the column
minWidth: 50, //The minimum width of the column
isSort: true, //Whether this column is allowed to be sorted, the default is to allow sorting
isAllowHide: true, //Whether hiding is allowed, if allowed, it will appear in the [Show/Hide column right-click menu]
type: 'string', //Type, used for sorting
//Custom cell renderer
render: function (record, rowindex, value, column) {
//This here points to grid
//record row data
//rowindex row index
//value current value, corresponding to record[column.name]
//column column information
return value; //return this HTML content displayed in the cell (generally organized according to value and row content)
},
//Column summary
totalSummary: {
align: 'center', //Summary cell content Alignment: left/center/right
type: 'count', //Summary type sum, max, min, avg, count. Can multiple types at the same time
render: function (e) { //Summary renderer, return html to load into the cell
//e Summary Object (including sum, max, min, avg, count)
return "
Total count:" e.count "
";
}
},
//Cell editor
editor: {
type: ' text'
},
//Multiple table headers support
columns: null
},

The columns of the table provide a very complete interface that can be expanded. Whether it is content cells or header cells, the content, layout, and size can be customized.
Custom header
For example, in the header, we can set the display directly to a piece of html:
Copy code Code As follows:

{
display: 'Department', //The text displayed in the header column, Support html
name: 'name',
align: 'left'
},

or use headerRender:
Copy code The code is as follows:

//Header content custom function
headerRender: function (column) {
return "< b>" column.display "";
},

Rendering

Custom cell
The name of column is the attribute that defines which cell is linked to the row data. For example, in the first line of the above example, if name is configured as id, then it should be displayed as "01". If it is configured as name, then it should be displayed as "department 01". There is also the align parameter, which determines the alignment of the cells.

If render is not configured, the content displayed in the cell will be determined by name.

Copy code The code is as follows:

{ name: 'id', display: 'Serial number', width: 200 },
{ name: 'name', display: 'name', width: 300 }


The above is the cell The default display mode. In addition to this method, formatters and custom functions can also be used.
Display rules for cell content:
, if render is configured, use render
. If the type parameter of column extends the corresponding formatter, then use the formatter for rendering. For example, the formatter
that defines the currency format is finally used. The default display mode
formatter
is implemented by extending $.ligerDefaults.Grid.formatters['columntype']. columntype is the column configuration. The type parameter. For example, if you want to format a currency format now:
Copy the code The code is as follows:

$.ligerDefaults.Grid.formatters['currency'] = function (num, column) {
//num current value
//column column information
if (!num ) return "$0.00";
num = num.toString().replace(/$|,/g, '');
if (isNaN(num))
num = "0.00";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num * 100 0.50000000001);
cents = num % 100;
num = Math .floor(num / 100).toString();
if (cents < 10)
cents = "0" cents;
for (var i = 0; i < Math.floor(( num.length - (1 i)) / 3); i )
num = num.substring(0, num.length - (4 * i 3)) ','
num.substring(num.length - (4 * i 3));
return "$" (((sign) ? '' : '-') '' num '.' cents);
};


In this way, as long as the column type is configured as currency. This function will be used to customize cell content
Copy code The code is as follows:

{ display: 'UnitPrice', name: 'UnitPrice', align: 'right' ,type:'currency' }

Rendering


Custom cell function
Custom cell function refers to configuring the render of column. We can organize arbitrary html.

Copy code The code is as follows:

var grid = $("#maingrid").ligerGrid ({
columns: [
{ name: 'id', display: 'serial number', width: 100,
render: function (record, rowindex, value, column) {
//this This points to grid
//record row data
//rowindex row index
//value current value, corresponding to record[column.name]
//column column information
return "< ;a href='edit.htm?id=" value "'>Edit";
}
},
{ name: 'id', display: 'serial number', width: 120,
render: function (record, rowindex, value, column) {
return '';
}
},
{ name: 'name', display: 'name', width: 300 }
],
data: { Rows: griddata }
});

Rendering


Cell Editor
All editor constructs are defined in $.ligerDefaults.Grid.editors, such as

Copy code The code is as follows:

editor: { type: 'spinner' }

will use $ .ligerDefaults.Grid.editors['spinner'] to create editors to build.

ligerGrid provides built-in editors such as check boxes, text boxes, dates, numeric adjusters, and drop-down boxes.

Rendering

There are many parameters for column. I will not list them all here. I only introduce a few commonly used parameters
For more, you can view the API: http:// api.ligerui.com
Sort and paging
There are also two ways of sorting and paging. One is local sorting and paging. One is server sorting and paging. Only local methods are introduced here.
The default situation. Sorting and paging are enabled. If you want to cancel the paging function, as follows:
Copy code The code is as follows:

usePager: false

效果圖

事件和方法
事件
事件名 參數(shù) 描述
onAfterAddRow (e) 增加行后事件
onAfterBeginEdit (e) 開始編輯后事件
onAfterChangeColumnWidth (column, newwidth) 改變列寬度事件
onAfterShowData (data) 顯示完數(shù)據(jù)事件
onAfterSubmitEdit (e) 提交編輯 事件
onBeforeChangeColumnWidth (column, newwidth) 驗(yàn)證 改變列寬度 是否通過
onBeforeCheckAllRow (checked, grid element) 選擇前事件,可以通過return false阻止操作(復(fù)選框 全選/全不選)
onBeforeEdit (e) 編輯前事件
onBeforeShowData (data) 顯示數(shù)據(jù)前事件,可以通過reutrn false阻止操作
onBeforeSubmitEdit (e) 驗(yàn)證編輯器結(jié)果是否通過
onBeginEdit (e) 驗(yàn)證 開始編輯 是否通過
onCancelEdit (e) 取消編輯 事件
onChangeSort () 改變排序事件
onCheckAllRow (checked, grid element) 選擇事件(復(fù)選框 全選/全不選)
onCheckRow (checked, rowdata, rowindex, rowDomElement) 選擇事件(復(fù)選框)
onContextmenu (parm, e) 右擊事件
onDblClickRow (rowdata, rowindex, rowDomElement) 雙擊行事件
onDragCol (node) 拖動(dòng)列事件
onError () 錯(cuò)誤事件
onLoaded () 加載完函數(shù)
onLoading () 加載時(shí)函數(shù)
onReload () 刷新事件,可以通過return false來阻止操作
onSelectRow (rowdata, rowindex, rowDomElement) 選擇行事件
onSubmit () 提交前事件
onSuccess () 成功事件
onToFirst () 第一頁,可以通過return false來阻止操作
onToggleCol () 切換列事件
onToLast () 最后一頁,可以通過return false來阻止操作
onToNext () 下一頁,可以通過return false來阻止操作
onToPrev () 上一頁,可以通過return false來阻止操作
onUnSelectRow (rowdata, rowindex, rowDomElement) 取消選擇行事件

Example

Copy code The code is as follows:

var grid = $("#maingrid").ligerGrid({
columns: [
{ name: 'id', display: 'serial number', width: 200 },
{ name: 'name', display : 'name', width: 300 }
],
data: { Rows: griddata },
onSelectRow: function (rowdata, rowindex) {
//Row records for data rows
//Row index, starting from 0
alert(rowdata.name);
}
});
grid.bind('SelectRow', function (rowdata, rowindex) {
//this This here all points to the grid

//The row record is for the data row
//The row index starts from 0
alert(rowdata.name);
});

方法
方法 參數(shù) 描述
addEditRow (rowdata)
  • 增加一個(gè)編輯行
addRow (rowdata, rowParm, isBefore, parentRow)
  • 增加新行
addRows (rowdataArr)
  • 一次性增加多行
appendRow (rowData, targetRow, nearRow, isBefore)
  • 附加新行(樹模式)
beginEdit (rowParm)
  • 進(jìn)入編輯狀態(tài)
cancelEdit (rowParm)
  • 取消編輯
changeHeaderText (columnparm, headerText)
  • 改變表頭文本
changePage (ctype)
  • 改變分頁
changeSort (columnName, sortOrder)
  • 改變排序
collapse (targetRow)
  • 收縮(樹模式)
collapseDetail (rowParm)
  • 收縮明細(xì)
deleteRow (rowParm)
  • 選擇行
deleteSelectedRow ()
  • 刪除選擇的行
demotion (targetRow)
  • 降級(jí)(樹模式)
endEdit (rowParm)
  • 結(jié)束編輯
expand (targetRow)
  • 展開(樹模式)
extendDetail (rowParm)
  • 展開明細(xì)
formatRecord (record)
  • 格式化數(shù)據(jù),刪除系統(tǒng)字段
getAdded ()
  • 獲取新增的數(shù)據(jù)
getCheckedRowObjs ()
  • 獲取選中的行 DOM對(duì)象集合
getCheckedRows ()
  • 獲取選中的行數(shù)據(jù)(復(fù)選框)
getChidren (rowParm)
  • 獲取子節(jié)點(diǎn)數(shù)據(jù)(樹模式)
getColumn (columnpam)
  • 獲取列信息
getColumns (columnLevel)
  • 獲取指定層級(jí)的Columns
getColumnType (columnname)
  • 根據(jù)列名獲取列類型
getData (status, removeStatus)
  • 獲取數(shù)據(jù)
getDeleted ()
  • 獲取刪除過的數(shù)據(jù)
getParent (rowParm)
  • 獲取父節(jié)點(diǎn)數(shù)據(jù)(樹模式)
getRowObj (rowParm)
  • 行DOM轉(zhuǎn)換為行數(shù)據(jù)
getSelected ()
  • 獲取選中的行數(shù)據(jù)(同getSelectedRow)
getSelectedRow ()
  • 獲取選中的行數(shù)據(jù)
getSelectedRowObj ()
  • 獲取選中的行 DOM對(duì)象
getSelectedRowObjs ()
  • 獲取選中的行 DOM對(duì)象集合
getSelectedRows ()
  • 獲取選中的行數(shù)據(jù)集合(支持Ctrl多選)
getSelecteds ()
  • 獲取選中的行數(shù)據(jù)集合(支持Ctrl多選)(同getSelectedRows)
getUpdated ()
  • 獲取修改過的數(shù)據(jù)
hasChildren (rowParm)
  • 是否包括子節(jié)點(diǎn)(樹模式)
isLeaf (rowParm)
  • 是否葉節(jié)點(diǎn)(樹模式)
isTotalSummary ()
  • 是否包含匯總
loadData (loadDataParm)
  • 刷新數(shù)據(jù)
loadServerData (param, clause)
  • 加載數(shù)據(jù)(服務(wù)器)
reRender (e)
  • 重新加載html
setColumnWidth (columnparm, value)
  • 調(diào)整列寬
setOptions (parms)
  • 重新設(shè)置參數(shù)(同名方法set)
SubmitEdit (rowParm)
  • 提交編輯
toggle (targetRow)
  • 伸展/收縮節(jié)點(diǎn)(樹模式)
toggleCol (columnparm, visible)
  • 顯示/隱藏列
updateCell (cell, value, rowParm)
  • 更新單元格
updateRow (newRowData, rowDom)
  • Update row
upgrade (targetRow)
  • Upgrade (tree mode)
Example
Copy code The code is as follows:

Copy Code The code is as follows:

var grid = $("#maingrid").ligerGrid({
columns: [
{ name: 'id ', display: 'serial number', width: 200 },
{ name: 'name', display: 'name', width: 300 }
]
});

grid .set({ data: { Rows: griddata} });

function selectRow(index) {
grid.select(index);
}
function getSelectRow() {
var rows = grid.getSelecteds();
for (var i in rows) {
alert(rows[i].name);
}
}
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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1501
276
How to make an HTTP request in Node.js? How to make an HTTP request in Node.js? Jul 13, 2025 am 02:18 AM

There are three common ways to initiate HTTP requests in Node.js: use built-in modules, axios, and node-fetch. 1. Use the built-in http/https module without dependencies, which is suitable for basic scenarios, but requires manual processing of data stitching and error monitoring, such as using https.get() to obtain data or send POST requests through .write(); 2.axios is a third-party library based on Promise. It has concise syntax and powerful functions, supports async/await, automatic JSON conversion, interceptor, etc. It is recommended to simplify asynchronous request operations; 3.node-fetch provides a style similar to browser fetch, based on Promise and simple syntax

JavaScript Data Types: Primitive vs Reference JavaScript Data Types: Primitive vs Reference Jul 13, 2025 am 02:43 AM

JavaScript data types are divided into primitive types and reference types. Primitive types include string, number, boolean, null, undefined, and symbol. The values are immutable and copies are copied when assigning values, so they do not affect each other; reference types such as objects, arrays and functions store memory addresses, and variables pointing to the same object will affect each other. Typeof and instanceof can be used to determine types, but pay attention to the historical issues of typeofnull. Understanding these two types of differences can help write more stable and reliable code.

JavaScript time object, someone builds an eactexe, faster website on Google Chrome, etc. JavaScript time object, someone builds an eactexe, faster website on Google Chrome, etc. Jul 08, 2025 pm 02:27 PM

Hello, JavaScript developers! Welcome to this week's JavaScript news! This week we will focus on: Oracle's trademark dispute with Deno, new JavaScript time objects are supported by browsers, Google Chrome updates, and some powerful developer tools. Let's get started! Oracle's trademark dispute with Deno Oracle's attempt to register a "JavaScript" trademark has caused controversy. Ryan Dahl, the creator of Node.js and Deno, has filed a petition to cancel the trademark, and he believes that JavaScript is an open standard and should not be used by Oracle

What is the cache API and how is it used with Service Workers? What is the cache API and how is it used with Service Workers? Jul 08, 2025 am 02:43 AM

CacheAPI is a tool provided by the browser to cache network requests, which is often used in conjunction with ServiceWorker to improve website performance and offline experience. 1. It allows developers to manually store resources such as scripts, style sheets, pictures, etc.; 2. It can match cache responses according to requests; 3. It supports deleting specific caches or clearing the entire cache; 4. It can implement cache priority or network priority strategies through ServiceWorker listening to fetch events; 5. It is often used for offline support, speed up repeated access speed, preloading key resources and background update content; 6. When using it, you need to pay attention to cache version control, storage restrictions and the difference from HTTP caching mechanism.

Handling Promises: Chaining, Error Handling, and Promise Combinators in JavaScript Handling Promises: Chaining, Error Handling, and Promise Combinators in JavaScript Jul 08, 2025 am 02:40 AM

Promise is the core mechanism for handling asynchronous operations in JavaScript. Understanding chain calls, error handling and combiners is the key to mastering their applications. 1. The chain call returns a new Promise through .then() to realize asynchronous process concatenation. Each .then() receives the previous result and can return a value or a Promise; 2. Error handling should use .catch() to catch exceptions to avoid silent failures, and can return the default value in catch to continue the process; 3. Combinators such as Promise.all() (successfully successful only after all success), Promise.race() (the first completion is returned) and Promise.allSettled() (waiting for all completions)

Leveraging Array.prototype Methods for Data Manipulation in JavaScript Leveraging Array.prototype Methods for Data Manipulation in JavaScript Jul 06, 2025 am 02:36 AM

JavaScript array built-in methods such as .map(), .filter() and .reduce() can simplify data processing; 1) .map() is used to convert elements one to one to generate new arrays; 2) .filter() is used to filter elements by condition; 3) .reduce() is used to aggregate data as a single value; misuse should be avoided when used, resulting in side effects or performance problems.

JS roundup: a deep dive into the JavaScript event loop JS roundup: a deep dive into the JavaScript event loop Jul 08, 2025 am 02:24 AM

JavaScript's event loop manages asynchronous operations by coordinating call stacks, WebAPIs, and task queues. 1. The call stack executes synchronous code, and when encountering asynchronous tasks, it is handed over to WebAPI for processing; 2. After the WebAPI completes the task in the background, it puts the callback into the corresponding queue (macro task or micro task); 3. The event loop checks whether the call stack is empty. If it is empty, the callback is taken out from the queue and pushed into the call stack for execution; 4. Micro tasks (such as Promise.then) take precedence over macro tasks (such as setTimeout); 5. Understanding the event loop helps to avoid blocking the main thread and optimize the code execution order.

Understanding Event Bubbling and Capturing in JavaScript DOM events Understanding Event Bubbling and Capturing in JavaScript DOM events Jul 08, 2025 am 02:36 AM

Event bubbles propagate from the target element outward to the ancestor node, while event capture propagates from the outer layer inward to the target element. 1. Event bubbles: After clicking the child element, the event triggers the listener of the parent element upwards in turn. For example, after clicking the button, it outputs Childclicked first, and then Parentclicked. 2. Event capture: Set the third parameter to true, so that the listener is executed in the capture stage, such as triggering the capture listener of the parent element before clicking the button. 3. Practical uses include unified management of child element events, interception preprocessing and performance optimization. 4. The DOM event stream is divided into three stages: capture, target and bubble, and the default listener is executed in the bubble stage.

See all articles