Created
June 22, 2014 15:08
-
-
Save gundisalwa/cdb067df2801fe5b63ca to your computer and use it in GitHub Desktop.
Dynamic Coltype addIn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Dynamic colType (AddIn) | |
* | |
* This addIn allows a control of the addIn called on a cell basis, rather than on a | |
* column basis only. | |
* | |
* Options: | |
* - colType: 'formattedText' by default. This can be controlled by passing a state | |
* dependant function to the registered addIn options. | |
* - compName: atm the addIn needs to have access to the component where the options | |
* are defined, so it needs to have that component name passed. | |
*/ | |
Dashboards.registerAddIn("Table", "colType", new AddIn({ | |
name: "dynamicColType", | |
label: "Dynamic colType", | |
defaults: { | |
colType: "formattedText", | |
// TODO: find some other way to pass the component??? | |
compName: undefined | |
}, | |
init: function(){ | |
$.fn.dataTableExt.oSort[this.name+'-asc'] = $.fn.dataTableExt.oSort['string-asc']; | |
$.fn.dataTableExt.oSort[this.name+'-desc'] = $.fn.dataTableExt.oSort['string-desc']; | |
}, | |
implementation: function(tgt, st, opt){ | |
if (opt.compName && Dashboards.hasAddIn('Table','colType', opt.colType)){ | |
var comp = Dashboards.getComponentByName(opt.compName), | |
addIn = comp.getAddIn("colType",opt.colType), | |
addInOpts = comp.getAddInOptions("colType",opt.colType); | |
addIn.call(tgt,st,addInOpts); | |
$(tgt).addClass(opt.colType); | |
} | |
} | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment