


Table control implemented by tbl.js div, completely free and does not rely on jquery
There is a relatively easy-to-use form control on html, which is datatable, but the editing, buttons
and other parts are charged, and only the basic functions are free. Moreover, when the size changes, it requires manual refresh and other tedious operations. So I developed a free one for everyone to use.This project has been used in the "VoidService Server Development Kit". Currently, it mainly supports Microsoft Edge browser, Chrome browser, others
have not been tested.tbl.js is completely free and can be modified at will. Welcome for
k.tbl.js supports list style, add, delete, modify, query, whole table search, grouping, paging function
, whole table editing, whole row Editing, single selection, multiple selection, style customization.can be embedded in various containers, such as jquery
's dialog and tabs. Version: 0.1betaReport a bug and I will fix it as soon as possible. There is no break in the New Year. If you do not need to modify the style, you do not need to load tbl.css, tbl.js will dynamically load the style sheet.Let's create a two-row table, built from existing DOM nodes
.1 html:<html><body><p></p></body></html> 2 new tbl(document.body.children[0],{data:[["row1"],["row2"]]});
1 var tb = new tbl(); 2 with (document.body) { insertBefore(tb.dom, firstChild) }; 3 tb.bind([["row1"],["row2"]]);
1 var tb = new tbl(undefined, {format:[{width:"20%"},{width:"20%"},{width:"20%"},{width:"20%"},{width:"20%"}]}); 2 with (document.body) { insertBefore(tb.dom, firstChild) }; 3 tb.bind([["row1","data","data","data","data"],["row2","data","data","data","data"]]);
1 html:<html><body><p></p></body></html> 2 var tb = new tbl(document.body.children[0], { 3 editable: false, maxheight: "300px", header: false, title: false, footer: false, data: [[1], [2, "remove"], ["nan - not a number", "del"], [4, "del"], [5, "del"]], page_size: 100, 4 format: [ 5 { width: "90%", nancenter: true, input: {type:"text"}}, 6 { width: "10%", editable:true, input: { type: "button", value:"del", onclick: function () { tb.delete(tb.get_related_rowid(this));}}} 7 ] 8 });
We initialize a data first. The data bound by tbl.js must be an array
. I expect that the second column cannot be edited under any circumstances.1 var tb_data = []; 2 for (var i = 0; i < 106; i++) { 3 tb_data[i] = [Math.random()>0.5?true:false, Math.random(), "1970-01-01", Math.floor(Math.random()*10), i, 0]; 4 } 5 tb_data[i] = "this is group"; i++; 6 tb_data[i] = ["this is text"]; i++; 7 for (; i < 578; i++) { 8 tb_data[i] = [i, Math.random(), "2017-02-01"]; 9 } 10 var tb = new tbl(document.body.children[0], { 11 editable:true,select:tbl.single,must_select:true,paging:true,data:tb_data,page_size:15, 12 format: [ 13 { width: "5%", input: { type: "checkbox", check: "true" } }, 14 { width: "30%", name:"name", uneditable:true }, 15 { width: "20%", name:"date", input: { type: "date" } }, 16 { width: "10%", name:"select", input: {type:"select", options:[0,1,2,3,4,5,6,7,8,9]} }, 17 { width: "20%" }, 18 { width: "15%", input: {type:"radio", name:"only"}} 19 ] 20 });
insert Insert data
bind bind new data sourcedelete Delete
one row Clean upedit Edit a row, empty parameter means edit the entire tableselect Select a rowcancel_edit Cancel editingcancel_select Cancel selectionselect_change Select to changeFunction
SettingsRead-onlyAttributes
:tbl::selects Selected rowstbl::data datatbl::dom DOM nodetbl::edits The row being edited, full table editing is not applicableConstruction options:
max_height Maximum height, scroll bars will be displayed if it exceeds
page_size Page size
data Initialization data
header Whether to display the header
footer Whether to display the footer
info Whether to display information
paging Whether to display paging
title_bar Display title bar
title Title bar text
search Display search box
editable Full table editing
select Type of selection: 0, cannot be selected. 1, radio selection . 2, multi-select.tbl.single == 1, tbl.multiselect == 2 select_change Set selectionEvent processing
Function
must_select Must select a row
format Column format
width Width, can be a valid html width. For example: 100px or 20%. input is used to edit the input node attribute of status
, which is the same as the html/input attribute
name field name, displayed in the header
uneditable columns will not be able to Edited
editable columns will always be in editable state
The above is the detailed content of Table control implemented by tbl.js div, completely free and does not rely on jquery. For more information, please follow other related articles on the PHP Chinese website!

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

To achieve the effect of scattering and enlarging the surrounding images after clicking on the image, many web designs need to achieve an interactive effect: click on a certain image to make the surrounding...

The Y-axis position adaptive algorithm for web annotation function This article will explore how to implement annotation functions similar to Word documents, especially how to deal with the interval between annotations...

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.
