search
HomeWeb Front-endHTML TutorialTable 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.1beta

Report 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:<p></p>
2 new tbl(document.body.children[0],{data:[["row1"],["row2"]]});
Insert the self-created DOM node into the document body.


1 var tb = new tbl();
2 with (document.body) { insertBefore(tb.dom, firstChild) };
3 tb.bind([["row1"],["row2"]]);
For tables with multiple fields, the column widths are adaptive using percentages.


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"]]);
List style, maximum height300px, no header, no title, no footer, 5 pieces of data, button, get rowindex.

This method will cause interlaced color changes, and the CSS can be modified to invalidate the style.


1 html:<p></p>
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 });
Full table editing, single selection, one row must be selected, paging.

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 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 <a href="http://www.php.cn/js/js-weixinapp-api.html" target="_blank"></a>API:<p></p>add is added at the end. The added row of data must be an array. Non-array will be used as the group title text. <p><a href="http://www.php.cn/code/5336.html" target="_blank">insert </a>Insert data</p><p></p>bind bind new data source<p><a href="http://www.php.cn/php/php-tp-remove.html" target="_blank">delete </a>Delete </p>one row<p><a href="http://www.php.cn/wiki/917.html" target="_blank"></a>clear</p> Clean up<p></p>edit Edit a row, empty parameter means edit the entire table<p></p>select Select a row<p></p>cancel_edit Cancel editing<p></p>cancel_select Cancel selection<p><a href="http://www.php.cn/wiki/145.html" target="_blank">select_change Select to change</a>Function</p>Settings<p><a href="http://www.php.cn/wiki/169.html" target="_blank">Read-only</a>Attributes</p>:<p></p>tbl::selects Selected rows<p></p>tbl::data data<p></p>tbl::dom DOM node<p></p>tbl::edits The row being edited, full table editing is not applicable<p></p>Construction options:<p><br>max_height Maximum height, scroll bars will be displayed if it exceeds <br> page_size Page size <br> data Initialization data <br> header Whether to display the header <br> footer Whether to display the footer <br> info Whether to display information <br> paging Whether to display paging <br> title_bar Display title bar <br> title Title bar text <br> search Display search box <br> editable Full table editing <br> select Type of selection: 0, cannot be selected. 1, radio selection . 2, multi-select.tbl.single == 1, tbl.multiselect == 2<a href="http://www.php.cn/code/5690.html" target="_blank"> select_change Set selection</a>Event processing<br>Function<br> must_select Must select a row<br> format Column format<br> width Width, can be a valid html width. For example: 100px or 20%.<a href="http://www.php.cn/code/8243.html" target="_blank"> input is used to edit the input node attribute of </a> status<br>, which is the same as the html/input attribute <br> name field name, displayed in the header <br> uneditable columns will not be able to Edited<br> editable columns will always be in editable state</p> nancenter Non-numeric centering###

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!

Statement
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
HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

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

The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTML and Code: A Closer Look at the TerminologyHTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AM

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS, and JavaScript: Essential Tools for Web DevelopersHTML, CSS, and JavaScript: Essential Tools for Web DevelopersApr 09, 2025 am 12:12 AM

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.

The Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesThe Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesApr 08, 2025 pm 07:05 PM

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.

See all articles

Hot AI Tools

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.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor