In this short tip, I provide a few easy steps to set up an editable grid (or table) using Bootstrap and Shield UI Lite.
Shield UI Lite is an open source jQuery library that includes, among other components, a jQuery grid. The grid supports editing out-of-the-box, as well as sorting, grouping, and different column editors.
Key Takeaways
- Shield UI Lite is an open source jQuery library that includes a jQuery grid, supporting editing, sorting, grouping, and different column editors. The grid also supports the binding of all types of data, from local JSON structures to remote web services.
- To set up an editable grid, you need to use a standard Bootstrap container, add references to all the resources used in the sample, such as stylesheets, JavaScript files, and data, and then set up the Shield UI Lite grid component. The grid can be customized using CSS and is compatible with other JavaScript libraries.
- The editable grid can be used with a database, can load data from various sources such as a local array, a JSON file, or a remote server, and can export data to various formats such as CSV, Excel, and PDF. It also supports built-in validation features and error handling.
About Shield UI Lite
Shield UI is a web component development company that specializes in the design, development, and marketing of UI widgets for pure JavaScript development, as well as for development in ASP.NET, ASP.NET MVC, and Java Wicket. The company offers Data Visualization components, as well as a whole array of standard web development components, such as grids, barcodes – one and two dimensional, extended input components – such as numeric and masked textboxes, and many more.
The Shield UI Lite Suite is one of the newest open source libraries on the market and what is specific about it is that it contains a wealth of components, all of which are feature rich and mature. This includes the jQuery Grid, which supports all important web grid operations out-of-the-box. The component supports editing with either inline or standard edit form editing, as well as editing with an external form. Also supported is cell editing.
In addition to this, the Shield UI Grid has a built-in datasource component, which facilitates the binding to all types of data – from local JSON structures, to remote web services; the built-in DataSource also takes care of all delete, update and insert operations.
For data-heavy applications, the Shield UI jQuery widget offers an enhanced virtual scrolling feature significantly improves performance, even when working with millions of real data records. To see more examples of the component and its options, you can refer to the online demos or the documentation.
Using the Code
For the editable grid that we’ll be creating, I’m using a local data source in order to keep things simple. The source code for the libraries can be found on GitHub. The full sample code, along with all sample data used, as well as additional CSS is available in the CodePen demo.
The first step in setting up the layout is to use a standard Bootstrap container. In our case, this is a div with a Bootstrap panel nested inside. Since any standard web grid component usually hosts a lot of data, our layout spans the full width of the screen.
The code for this step is straightforward and looks like this:
<span><span><span><div> class<span>="col-md-12"</span>> <span><span><span><div> class<span>="panel panel-default"</span>> <span><span><span><div> class<span>="panel-heading"</span>> <span><span><span><h4 id="class-span-text-center-span-gt"> class<span>="text-center"</span>></h4></span>Bootstrap Editable jQuery Grid </span> <span><span><span><span> class<span>="fa fa-edit pull-right bigicon"</span>></span><span><span></span></span>></span><span><span></span>></span> </span> <span><span><span></span></span></span></span></span> </div></span>></span> </span> <span><span><span><div> class<span>="panel-body text-center"</span>> <span><span><span><div> id<span>="grid"</span>><span><span></span></span> </div></span>></span> </span> <span><span><span></span></span></span> </div></span>></span> </span> <span><span><span></span></span></span> </div></span>></span> </span><span><span><span></span></span></span> </div></span>></span></span>
This is all the HTML needed to set up the sample. The next step is adding references to all the resources used in the sample, such as stylesheets, JavaScript files, and data.
The data used for the example is a standard JSON collection, which is loaded separately in order to be passed to the grid component. Using a local data source simplifies the setup. Additionally we need the stylesheet for the grid and the JavaScript for initializing it.
The inclusion of these resources is demonstrated below:
The CSS:
<span><span><span><link> rel<span>="stylesheet"</span> href<span>="shieldui-lite.min.css"</span>></span></span></span>
The scripts:
<span><span><span><script> src<span >="shieldui-lite-all.min.js"</script></span>></span><span><span></span>></span> </span><span><span><span><script> src<span >="shortGridData.js"</script></span>></span><span><span></span>></span></span>
Setting up the Grid
The next step in the process is setting up the Shield UI Lite grid component. Once we have included the necessary resources, we can initialize it with some JavaScript in the document.ready handler.
There are two logical parts in describing the component. The first is handling the datasource for the data that will be visualized in the grid, and the other one is setting up the columns, which will be actually rendered, as well as any additional settings, such as sorting, hover effects, etc.
The Shield UI Lite Grid has a built-in dataSource property, which makes it easy to bind the widget to any data – local or remote. To link the dataSource to the JSON data, we use the data property and describe the fields, which will be fetched.
The code to achieve this is shown below:
<span>dataSource: { </span> <span>data: gridData, </span> <span>schema: { </span> <span>fields: { </span> <span>id: { path: "id", type: Number }, </span> <span>age: { path: "age", type: Number }, </span> <span>name: { path: "name", type: String }, </span> <span>company: { path: "company", type: String }, </span> <span>month: { path: "month", type: Date }, </span> <span>isActive: { path: "isActive", type: Boolean }, </span> <span>email: { path: "email", type: String }, </span> <span>transport: { path: "transport", type: String } </span> <span>} </span> <span>} </span><span>}</span>
Enabling Editing
The next step in the process of setting up the application is choosing which properties will be available in the grid, as well as describing the columns, which will be rendered.
Each column can have additional properties, such as header text and width. The width property setting is not obligatory, but provides additional flexibility for distributing the overall layout.
The code for all the properties in the control is listed below:
<span><span><span><div> class<span>="col-md-12"</span>> <span><span><span><div> class<span>="panel panel-default"</span>> <span><span><span><div> class<span>="panel-heading"</span>> <span><span><span><h4 id="class-span-text-center-span-gt"> class<span>="text-center"</span>></h4></span>Bootstrap Editable jQuery Grid </span> <span><span><span><span> class<span>="fa fa-edit pull-right bigicon"</span>></span><span><span></span></span>></span><span><span></span>></span> </span> <span><span><span></span></span></span></span></span> </div></span>></span> </span> <span><span><span><div> class<span>="panel-body text-center"</span>> <span><span><span><div> id<span>="grid"</span>><span><span></span></span> </div></span>></span> </span> <span><span><span></span></span></span> </div></span>></span> </span> <span><span><span></span></span></span> </div></span>></span> </span><span><span><span></span></span></span> </div></span>></span></span>
Setting Up a Custom Editor
The widget supports a number of handy editors out of the box. Once the control is put into edit mode, by clicking on any of the cells, the editor for the cell will be dependent on the type of values in this cell. For example, a numeric value will have a numeric input with increment and decrement buttons. A date column will have a Calendar input for easily picking a date.
There is also the option of supplying a custom editor for a column. For example, instead of having a standard textbox, we can have a dropdown with all the values for that column.
This can be achieved by attaching to the getCustomEditorValue event and passing a custom editor for each cell.
This is demonstrated in the following code snippet for the events:
<span><span><span><link> rel<span>="stylesheet"</span> href<span>="shieldui-lite.min.css"</span>></span></span></span>
And the custom editor:
<span><span><span><script> src<span >="shieldui-lite-all.min.js"</script></span>></span><span><span></span>></span> </span><span><span><span><script> src<span >="shortGridData.js"</script></span>></span><span><span></span>></span></span>
If you would like to review more information on the options in the grid widget, you can refer to this section of the documentation.
This completes our setup and the control is ready to use.
View the full working demo on CodePen
Be sure to click inside any of the content cells in the table/grid to see how the edit functionality works. You can view more examples on the usage of the Shield UI jQuery Grid component on the Shield UI website.
Frequently Asked Questions (FAQs) about Editable Grid with jQuery and Bootstrap
How Can I Customize the Appearance of the Editable Grid?
The appearance of the editable grid can be customized using CSS. You can modify the grid’s colors, fonts, borders, and other visual elements to match your website’s design. You can also use Bootstrap’s built-in classes to quickly style your grid. For more advanced customizations, you can use Shield UI Lite’s API, which provides a variety of options for modifying the grid’s appearance and behavior.
Can I Use the Editable Grid with Other JavaScript Libraries?
Yes, the editable grid is compatible with other JavaScript libraries such as AngularJS, React, and Vue.js. You can use these libraries to enhance the functionality of your grid, such as adding dynamic data loading, sorting, and filtering capabilities.
How Can I Add or Remove Rows in the Editable Grid?
You can add or remove rows in the editable grid using the grid’s API. The API provides methods for adding new rows, deleting existing rows, and updating the data in the grid. You can also use the API to programmatically select rows, which can be useful for implementing bulk editing or deletion features.
How Can I Validate User Input in the Editable Grid?
You can validate user input in the editable grid using Shield UI Lite’s built-in validation features. The library provides a variety of validation rules, such as required fields, number ranges, and email formats. You can also create custom validation rules to handle more complex validation scenarios.
Can I Export the Data from the Editable Grid?
Yes, you can export the data from the editable grid to various formats such as CSV, Excel, and PDF. This can be done using the grid’s API, which provides methods for exporting the grid’s data. You can also customize the exported data, such as including or excluding certain columns, or formatting the data in a specific way.
How Can I Load Data into the Editable Grid?
You can load data into the editable grid from various sources such as a local array, a JSON file, or a remote server. The grid’s API provides methods for loading data, and you can use these methods in combination with AJAX to load data from a server.
Can I Use the Editable Grid in a Mobile Application?
Yes, the editable grid is responsive and can be used in a mobile application. The grid’s layout will automatically adjust to fit the screen size, and you can also customize the grid’s behavior on different devices using CSS media queries.
How Can I Sort and Filter Data in the Editable Grid?
You can sort and filter data in the editable grid using the grid’s API. The API provides methods for sorting data by one or more columns, and for filtering data based on various criteria. You can also use these methods in combination with AJAX to implement server-side sorting and filtering.
Can I Use the Editable Grid with a Database?
Yes, you can use the editable grid with a database. You can load data from a database into the grid, and you can also update the database with changes made in the grid. This can be done using AJAX in combination with a server-side language such as PHP, ASP.NET, or Node.js.
How Can I Handle Errors in the Editable Grid?
You can handle errors in the editable grid using Shield UI Lite’s built-in error handling features. The library provides methods for displaying error messages, highlighting invalid fields, and preventing invalid data from being saved. You can also customize the error handling behavior to suit your needs.
The above is the detailed content of An Editable Grid with jQuery, Bootstrap, and Shield UI Lite. For more information, please follow other related articles on the PHP Chinese website!

Detailed explanation of JavaScript string replacement method and FAQ This article will explore two ways to replace string characters in JavaScript: internal JavaScript code and internal HTML for web pages. Replace string inside JavaScript code The most direct way is to use the replace() method: str = str.replace("find","replace"); This method replaces only the first match. To replace all matches, use a regular expression and add the global flag g: str = str.replace(/fi

Leverage jQuery for Effortless Web Page Layouts: 8 Essential Plugins jQuery simplifies web page layout significantly. This article highlights eight powerful jQuery plugins that streamline the process, particularly useful for manual website creation

So here you are, ready to learn all about this thing called AJAX. But, what exactly is it? The term AJAX refers to a loose grouping of technologies that are used to create dynamic, interactive web content. The term AJAX, originally coined by Jesse J

10 fun jQuery game plugins to make your website more attractive and enhance user stickiness! While Flash is still the best software for developing casual web games, jQuery can also create surprising effects, and while not comparable to pure action Flash games, in some cases you can also have unexpected fun in your browser. jQuery tic toe game The "Hello world" of game programming now has a jQuery version. Source code jQuery Crazy Word Composition Game This is a fill-in-the-blank game, and it can produce some weird results due to not knowing the context of the word. Source code jQuery mine sweeping game

Article discusses creating, publishing, and maintaining JavaScript libraries, focusing on planning, development, testing, documentation, and promotion strategies.

This tutorial demonstrates creating dynamic page boxes loaded via AJAX, enabling instant refresh without full page reloads. It leverages jQuery and JavaScript. Think of it as a custom Facebook-style content box loader. Key Concepts: AJAX and jQuery

This tutorial demonstrates how to create a captivating parallax background effect using jQuery. We'll build a header banner with layered images that create a stunning visual depth. The updated plugin works with jQuery 1.6.4 and later. Download the

This JavaScript library leverages the window.name property to manage session data without relying on cookies. It offers a robust solution for storing and retrieving session variables across browsers. The library provides three core methods: Session


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

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
