Month: February 2015

Example make reusable javascript app for modal progress bootstrap

Example make reusable javascript app for modal progress bootstrap

This is example build reusable app in Javascript for modal progress in Boostrap: 123456789101112131415/**  * Re-usable app for modal box progress  */ var progressBox; progressBox = progressBox || (function() {     var pleaseWaitDiv =  $(‘<div class="modal hide" id="pleaseWaitDialog" data-backdrop="static" data-keyboard="false"><div class="modal-header"><h1>Processing…</h1></div><div class="modal-body"><div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div></div></div>’);     return {     …

+ Read More

How to hide search toolbar in Datatables

How to hide search toolbar in Datatables

Here is a quick snippet to hide search toolbar in datatables and working along with Bootstrap 1234var settings = {             sDom: ‘lrt<"col-sm-6"i><"col-sm-6"p>’,             serverSide : true, …

Set bootstrap datetimepicker input value date

Set bootstrap datetimepicker input value date

Here is a quick way to set value bootstrap datetimepicker input with date object: 123456$("#id_start_date, #id_end_date").datetimepicker({     format: "DD-MM-YYYY hh:mm" }); $(‘#id_start_date’).data("DateTimePicker").setDate(start); $(‘#id_end_date’).data("DateTimePicker").setDate(end);

Datatables make link in row records

Datatables make link in row records

Here is a quick snippet to make record as links in Datatables : 12345678columns : [               {                 "mRender": function ( data, type, full ) {                  // ‘full’ is the row’s data object, …

+ Read More

Change / Reset / Update Key Pem Amazon EC2 Simple

Change / Reset / Update Key Pem Amazon EC2 Simple

Here are simple tricks to change or update key PEM in Amazon EC2. At this example, I’m using Ubuntu. To reset or change key pem, all you need just follow this simple steps: Let say, currently we have SERVER_01 and KEYPEM_01. 1234561. Launch a new instances using "launch more like this" (right-click on instances) 2. …

+ Read More

Django check related model and check field if exists in model

Django check related model and check field if exists in model

We can check if the field is related model in Model by : 1model._meta.get_field("name_of_field").get_internal_type() == "ForeignKey" Then we can check if the field name is exists in model by : 1model._meta.get_field_by_name(_name) Some example code: 123456789101112131415if self.model._meta.get_field(field_name).get_internal_type() == "ForeignKey":     # get related model     # http://stackoverflow.com/questions/10347210/django-foreign-key-get-related-model     related_model = self.model._meta.get_field(field_name).rel.to     …

+ Read More

Mapping Ajax Filter and Search Datatables to Django with Rest Framework

Mapping Ajax Filter and Search Datatables to Django with Rest Framework

Datatables sending ajax parameter for filtering and search in very complicated way. Which we need to mapping and parse based on each column. Some example request : 1http://localhost:8000/api/somemodel/?format=json&sEcho=4&iColumns=7&sColumns=%2C%2C%2C%2C%2C%2C&iDisplayStart=0&iDisplayLength=10&mDataProp_0=&sSearch_0=&bRegex_0=false&bSearchable_0=true&mDataProp_1=cif&sSearch_1=22222&bRegex_1=false&bSearchable_1=true&mDataProp_2=name&sSearch_2=&bRegex_2=false&bSearchable_2=true&mDataProp_3=gender&sSearch_3=&bRegex_3=false&bSearchable_3=true&mDataProp_4=ktp&sSearch_4=&bRegex_4=false&bSearchable_4=true&mDataProp_5=location&sSearch_5=&bRegex_5=false&bSearchable_5=true&mDataProp_6=&sSearch_6=&bRegex_6=false&bSearchable_6=true&sSearch=&bRegex=false I have no idea about where the filtering and search query come from in this request. Therefore, we need to auto-mapping it by : 123456789101112131415161718import re from …

+ Read More

Disable sort on first column in Jquery Datatables

Disable sort on first column in Jquery Datatables

Dunno if this is bug or not, but disable sort in HTML nor Javascript will not affect for first column sorting in Datatables. The solution just define bSort = false 123456var table = $(‘#table-index’).dataTable({             serverSide : true,             sAjaxSource : url,       …

+ Read More

Solve ScrollTop Jquery not working in Boostrap because overflow:auto

Solve ScrollTop Jquery not working in Boostrap because overflow:auto

Yes, ScrollTop Jquery not working in Boostrap because overflow:auto. To solve this, we need to use div that using “overflow:auto” and solve by : 123456789101112<script type="text/javascript">            $(document).ready(function() {                                 /* smooth scrolling for scroll to …

+ Read More