


jQuery imitation Excel table editing function implementation code_jquery
Almost all operations that can be performed in Excel can be performed on the web, such as dragging and copying, Ctrl C, Ctrl V, etc.
In addition, in terms of browser support, it supports the following browsers IE7, FF, Chrome, Safari, Opera.
How to use:
First introduce the jQuery framework and the relevant JS and CSS files of the Handsontable plug-in into the page. The two listed below are necessary, and the others are optional. If you need a certain function Added when needed (see demo).
Then add a DIV layer for rendering the Excel editing table
Finally you can initialize it
//数据
var data = [
{id: 1, name: "Ted", isActive: true, color: "orange"},
{id: 2, name: "John", isActive: false, color: "black"},
{id: 3, name: "Al", isActive: true, color: "red"},
{id: 4, name: "Ben", isActive: false, color: "blue"}
];
//黄色渲染方法
var yellowRenderer = function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.TextCell.renderer.apply(this, arguments);
$(td).css({
background: 'yellow'
});
};
//绿色渲染方法
var greenRenderer = function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.TextCell.renderer.apply(this, arguments);
$(td).css({
background: 'green'
});
};
//初始化
var $container = $("#example1");
$container.handsontable({
data: data,
startRows: 5,
colHeaders: true,
minSpareRows: 1,
columns: [
{data: "id"},
{data: "name", type: {renderer: yellowRenderer}}, //黄色渲染
{data: "isActive", type: Handsontable.CheckboxCell}, //多选框
{data: "color",
type: Handsontable.AutocompleteCell, //自动完成
source: ["yellow", "red", "orange", "green", "blue", "gray", "black", "white"] //数据源
}
],
cells: function (row, col, prop) {
if (row === 0 && col === 0) {
return {type: {renderer: greenRenderer}};
}
}
});
Note that the div container is initialized after loading:
Demo code:
<script><br> $(function(){<br> //数据<br> var data = [<br> {id: 1, name: "Ted", isActive: true, color: "orange"},<br> {id: 2, name: "John", isActive: false, color: "black"},<br> {id: 3, name: "Al", isActive: true, color: "red"},<br> {id: 4, name: "Ben", isActive: false, color: "blue"}<br> ];<br> //黄色渲染方法<br> var yellowRenderer = function (instance, td, row, col, prop, value, cellProperties) {<br> Handsontable.TextCell.renderer.apply(this, arguments);<br> $(td).css({<br> background: 'yellow'<br> });<br> };<br> //绿色渲染方法<br> var greenRenderer = function (instance, td, row, col, prop, value, cellProperties) {<br> Handsontable.TextCell.renderer.apply(this, arguments);<br> $(td).css({<br> background: 'green'<br> });<br> };<br> //初始化<br> var $container = $("#example1");<br> $container.handsontable({<br> data: data,<br> startRows: 5,<br> colHeaders: true,<br> minSpareRows: 1,<br> columns: [<br> {data: "id"},<br> {data: "name", type: {renderer: yellowRenderer}}, //黄色渲染<br> {data: "isActive", type: Handsontable.CheckboxCell}, //多选框<br> {data: "color",<br> type: Handsontable.AutocompleteCell, //自动完成<br> source: ["yellow", "red", "orange", "green", "blue", "gray", "black", "white"] //数据源<br> }<br> ],<br> セル: function (row,col, prop) {<br> if (row === 0 &&col === 0) {<br> return {type: {renderer : greenRenderer}} ;<br> }<br> }<br> });<br> });<br> </script>

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

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



1. Create a new PPT file and name it [PPT Tips] as an example. 2. Double-click [PPT Tips] to open the PPT file. 3. Insert a table with two rows and two columns as an example. 4. Double-click on the border of the table, and the [Design] option will appear on the upper toolbar. 5. Click the [Shading] option and click [Picture]. 6. Click [Picture] to pop up the fill options dialog box with the picture as the background. 7. Find the tray you want to insert in the directory and click OK to insert the picture. 8. Right-click on the table box to bring up the settings dialog box. 9. Click [Format Cells] and check [Tile images as shading]. 10. Set [Center], [Mirror] and other functions you need, and click OK. Note: The default is for pictures to be filled in the table

Being able to skillfully make forms is not only a necessary skill for accounting, human resources, and finance. For many sales staff, learning to make forms is also very important. Because the data related to sales is very large and complex, and it cannot be simply recorded in a document to explain the problem. In order to enable more sales staff to be proficient in using Excel to make tables, the editor will introduce the table making issues about sales forecasting. Friends in need should not miss it! 1. Open [Sales Forecast and Target Setting], xlsm, to analyze the data stored in each table. 2. Create a new [Blank Worksheet], select [Cell], and enter [Label Information]. [Drag] downward and [Fill] the month. Enter [Other] data and click [

How to use JavaScript to realize the drag-and-drop adjustment function of table column width? With the development of Web technology, more and more data are displayed on web pages in the form of tables. However, sometimes the column width of the table cannot meet our needs, and the content may overflow or the width may be insufficient. In order to solve this problem, we can use JavaScript to implement the drag-and-drop adjustment function of the column width of the table, so that users can freely adjust the column width according to their needs. To realize the drag-and-drop adjustment function of table column width, the following three main points are required:

1. Open the worksheet and find the [Start]-[Conditional Formatting] button. 2. Click Column Selection and select the column to which conditional formatting will be added. 3. Click the [Conditional Formatting] button to bring up the option menu. 4. Select [Highlight conditional rules]-[Between]. 5. Fill in the rules: 20, 24, dark green text with dark fill color. 6. After confirmation, the data in the selected column will be colored with corresponding numbers, text, and cell boxes according to the settings. 7. Conditional rules without conflicts can be added repeatedly, but for conflicting rules WPS will replace the previously established conditional rules with the last added rule. 8. Repeatedly add the cell columns after [Between] rules 20-24 and [Less than] 20. 9. If you need to change the rules, you can just clear the rules and then reset the rules.

Sometimes, we often encounter counting problems in Word tables. Generally, when encountering such problems, most students will copy the Word table to Excel for calculation; some students will silently pick up the calculator. Calculate. Is there a quick way to calculate it? Of course there is, in fact the sum can also be calculated in Word. So, do you know how to do it? Today, let’s take a look together! Without further ado, friends in need should quickly collect it! Step details: 1. First, we open the Word software on the computer and open the document that needs to be processed. (As shown in the picture) 2. Next, we position the cursor on the cell where the summed value is located (as shown in the picture); then, we click [Menu Bar

How to implement the export and import of tabular data in Vue requires specific code examples. In web projects developed using Vue, we often encounter the need to export tabular data to Excel or import Excel files. This article will introduce how to use Vue to implement the export and import functions of table data, and provide specific code examples. 1. Installation dependencies for exporting table data First, we need to install some dependencies for exporting Excel files. Run the following command from the command line in your Vue project: npmin

Does anyone know how to edit documents in Tencent Docs? It doesn't matter if you don't know. Today, the editor will introduce detailed graphic explanations on how to edit documents in Tencent Docs. I hope it can help you. Detailed graphic explanation of editing documents in Tencent Documents 1. First, enter Tencent Documents directly (if you don’t have it, download it now!) and log in directly (QQ and TIM two login methods are supported) 2. After logging in, click Add in the upper right corner No., directly create online documents, online forms, new folders, etc.! 3. Then enter the information according to your needs!

Using JavaScript to implement table filtering function With the continuous development of Internet technology, tables have become a common way to display data on web pages. However, when the amount of data is huge, users often face difficulties in finding specific data. Therefore, adding filtering functions to tables so that users can quickly find the required data has become a requirement for many web designs. This article will introduce how to use JavaScript to implement table filtering function. First, we need to have a table of data. Here's a simple example: <t
