Month: April 2015

Update parent after children new windows closed

Update parent after children new windows closed

Here is a snippet to update parent after new window getting closed : 12345678910111213141516171819// Start trigger pop-up new window var createUrl = $(this).data(‘url’) + selectedUUID; newwindow = window.open(createUrl, ‘Some Page, ‘scrollbars=yes,resizable=yes,height=600,width=’+screen.width/2); // Set focus on windows if (window.focus) {     newwindow.focus(); } // Update parent once children window already closed // Reload jqgrid table …

+ Read More

JqGrid inline editing integration with DJango send csrf token

JqGrid inline editing integration with DJango send csrf token

Here is a quick snippet to send csrf_token in POST data from inline edit JqGrid to Django: 12345678910111213141516var tableGrid = $(selector).jqGrid({    ….    onSelectRow: function(id){          if(id && id!==lastSel){             $(selector).restoreRow(lastSel);             lastSel=id;          }       …

+ Read More

Example Jquery Plugin to filtering input value real-time with Regex validation

Example Jquery Plugin to filtering input value real-time with Regex validation

We try to add real-time input validation for dynamic element with some regex. Let say, user allowed only to type “numeric” and disallow any others alphabet and symbols. Then, we can write a small plugin, at this example, i use https://github.com/akzhan/jquery-keyfilter for Regex validation. Then, we just need to write this simple and easy plugin …

+ Read More

Handle error form.save() with model validation

Handle error form.save() with model validation

Here is a quick snippet to avoid form.save() error because model validation : 12345678# handle form save with model validationerror # http://stackoverflow.com/questions/8771029/django-raise-a-validation-error-in-a-models-save-method try:     form.save() except ValidationError, e:     form._errors = {}     for _, v in e.message_dict.items():         form._errors.setdefault(NON_FIELD_ERRORS, []).extend(v)

Inline edit jqgrid with select2

Inline edit jqgrid with select2

Here is a quick snippet for inline edit JqGrid with Select2 First, we need to bind colModel with select2 in dataInit : 1234567891011121314var colModel = [      // always put uuid and id      {name:’id’, hidden: true},      {name:’uuid’, hidden: true},      {name:’youroption’, label:’yourlabel’,editable: true,       edittype: "select", editrules: …

+ Read More

Jqgrid for Dummies

Jqgrid for Dummies

Here is a quick snippet of how to using JqGrid for dummies, like get data, delete data, access data or data manipulation. Setup JQGrid: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970$(document).ready(function() {     // Enable tooltips $("body").tooltip({     selector : ‘[data-toggle="tooltip"]’ }); $(".chosen").chosen(); var permission = $(‘.permission’); // Define ID for table var selector = "#table-index"; var pager = …

+ Read More

JqGrid save inline editing callback

JqGrid save inline editing callback

Here is a quick snippet for callback when saving inline editing in JqGrid: 123456789101112// http://stackoverflow.com/questions/13303698/total-of-amount-in-jqgrid ondblClickRow: function (rowid, name, val, iRow, iCol) {     $(selector).jqGrid("editRow", rowid, {         keys: true,         aftersavefunc: function (rowid) {             var $grid = $(selector);       …

+ Read More

JqGrid delete multiple select rows

JqGrid delete multiple select rows

There is an issue if we delete rows using : 12345678910// Get all selected row var rows = $(selector).jqGrid("getGridParam", "selarrrow"); console.log(rows); // Iterate and delete for (var i in rows) {       console.log(i);       console.log(rows[i]);       $(selector).jqGrid(‘delRowData’, rows[i]); } Only a few records will deleted. The solution : 12345678910111213/** …

+ Read More