jquery4u.com - Archives (aout 2015)

1 jQuery Fan Blog for your Daily News, Plugins, Tuts/Tips & Code Snippets.

Le: 27 08 2015 à 20:30 Auteur: David Johnson

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.

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:

[code language="html"]
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="text-center">Bootstrap Editable jQuery Grid
<span class="fa fa-edit pull-right bigicon"></span></h4>
</div>
<div class="panel-body text-center">
<div id="grid"></div>
</div>
</div>
</div>
[/code]

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:

[code language="html"]
<link rel="stylesheet" href="shieldui-lite.min.css">
[/code]

The scripts:

[code language="html"]
<script src="shieldui-lite-all.min.js"></script>
<script src="shortGridData.js"></script>
[/code]

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.

Continue reading %An Editable Grid with jQuery, Bootstrap, and Shield UI Lite%

Le: 26 08 2015 à 22:54 Auteur: Aurelio De Rosa

Without any doubt Ajax has taken web development by storm and it's one of the most successful paradigms ever. In my article An Introduction to jQuery’s Shorthand Ajax Methods, I discussed some of jQuery's most used Ajax shorthand methods: $.get(), $.post(), and $.load(). They are convenient methods for making Ajax requests in a few lines of code.

Sometimes, we need more control over the Ajax calls we want to make. For example, we want to specify what should happen in case an Ajax call fails or we need to perform an Ajax request but its result is only needed if retrieved within a certain amount of time. In such situations, we can rely on another function provided by jQuery, called $.ajax(), that is the topic of this tutorial.

The $.ajax() Function

The jQuery's $.ajax() function is used to perform an asynchronous HTTP request. It was added to the library a long time ago, existing since version 1.0. The $.ajax() function is what every function discussed in the previously mentioned article calls behind the scene using a preset configuration. The signatures of this function are shown below:

[js]
$.ajax(url[, options])
$.ajax([options])
[/js]

The url parameter is a string containing the URL you want to reach with the Ajax call, while options is an object literal containing the configuration for the Ajax request.

In its first form, this function performs an Ajax request using the url parameter and the options specified in options. In the second form, the URL is specified in the options parameter, or can be omitted in which case the request is made to the current page.

The list of the options accepted by this function, described in the next section, is very long. So, I'll keep their description short. In case you want to study in-depth their meaning, you can refer to the official documentation of $.ajax().

The option Parameter

There are a lot of different options you can specify to bend $.ajax() to your need. In the list below you can find their names and their description sorted in alphabetic order:

Continue reading %How to Use jQuery’s $.ajax() Function%

Le: 14 08 2015 à 17:00 Auteur: Narayan Prusty

HealthKit is a framework introduced in iOS 8 that provides a centralized, user coordinated and secure datastore for health and fitness related information. The HealthKit datastore is shared among apps so that they can access health and fitness related data.

In this tutorial I will show you how a Cordova app can read and update HealthKit data. I will create a simple app which will let users update height, weight and vitamin C consumption. To access the HealthKit framework I will use Telerik’s HealthKit Cordova Plugin.

Continue reading %Using HealthKit with a Cordova App%