Sunday, February 26, 2012

jQuery Datatables plugin and Codeigniter


Just got an work around for the jQuery datatables wrapper [IgnitedDatatables] and made it working on a project to load huge data. As I din get any neat info I had to dig little deep both into datatables plugin and the wrapper and finally made a work around for me. Here in this post I am basically sharing my experience along with keeping records of what and how I did :)
The js I am using on the view to create the datatable and load using ajax is as follow [don try to run on jsFiddle 'cz it has lots of garbage- will clean it up :| ] :


Code on the controller:


And finally the model:


I will write in details on it - how I actually worked on later on this post.
Tips:
  1. For the callback function for the wrapper to work you need to create a helper file where you need to put all the callback functions.
  2. As the wrapper somewhat works as the model should work I have called and made use of it in my model class.
Reference:
  1. jQuery Datatables plugin api
  2. Server side data processing using Datatables plugin
  3. IgnitedDatatables function reference; and Method Chaining example
  4. Example usage code for the IgnitedDatatables library [independent of Codeigniter]
  5. Sample MySql Database [Sakila :)]

Sunday, February 12, 2012

Dynamically add a group of fields using jQuery

Its not a so tough thing, tough. Just wanted to keep a record and add a tip :) Following is the code I am using:

Note:
I was facing a problem, when the groups of fields grows  more then the view area for each click to create the window jumps to the top of the page; To resolve, to remain where I was creating the new fields I just added one line return false as the last line of the click even.
Instead of remaining the same place if you want to scroll to some where else you can use the following jQuery plugin:
scrollTo

Wednesday, February 8, 2012

Manipulating Auto Increment values in MySql



  1. Set the MySql variables auto_increment_increment and auto_increment_offset variables.
  2. Play with the Auto_Increment in Information schema.
To start with an AUTO_INCREMENT value other than 1, you can set that value with CREATE TABLE or ALTER TABLE, like this:
ALTER TABLE tbl AUTO_INCREMENT = 100;
Note:It is not possible to confine the effects of these two variables to a single table, and thus they do not take the place of the sequences offered by some other database management systems; these variables control the behavior of all AUTO_INCREMENT columns in all tables on the MySQL server. If the global value of either variable is set, its effects persist until the global value is changed or overridden by setting the session value, or until mysqld is restarted. If the local value is set, the new value affects AUTO_INCREMENT columns for all tables into which new rows are inserted by the current user for the duration of the session, unless the values are changed during that session.