I'm using DataTables 1.10.10. I would like to modify the main plugin Javascript to override the iDisplayLength value to -1. That way ALL my datatables show "All" by default, and the user can filter down if they wish.
Where in the file would this be set? I'm having trouble finding it. I've searched for iDisplayLength and tried overriding the value with -1, but it's not taking so I'm guessing it's being set somewhere that I'm not looking.
I think, changing the source files has main drawbacks. For example, in case you want to update the library, all changes are lost. Why not creating a personal plugin for the DataTables library. Like:
$.fn.myDataTable = function() {
$(this).dataTable( {
"iDisplayLength": -1
});
};
// call
$( ".allTables" ).myDataTable();
Found it. On line 6262 (in my jquery.dataTable.js file at least), before the following code
// Map the initialisation options to the settings object
_fnMap( oSettings.oFeatures, oInit, [ .....
I added the following line
oInit.iDisplayLength = -1;
DataTable now loads with show "All" always, even if the report has the iDisplayLength specified on it.
Related
This question already has an answer here:
How to use CKEDITOR.replace after CKEDITOR.inline
(1 answer)
Closed 5 years ago.
I have run the Toolbar Configurator to remove some unwanted items from the toolbar. I can get the toolbar config, which consists of some javascript code which starts like this:
CKEDITOR.editorConfig = function( config ) {
config.toolbarGroups = [
However, it is unclear to me how to use this when instantiating a specific editor instead of using it globally. I have tried pasting this in my code before I instantiate the editor in question, but it shows the full toolbar with the unwanted items. I am also making some other CKEDITOR.config and CKEDITOR.on assignments at this time which do work.
I also tried modifying the configuration code within the function by changing the config to editor.config (where editor comes from the "editor" field of the event passed to the callback) and initializing it in the callback of CKEDITOR.on("instanceReady") but that also did not work.
Then I saw this question and tried using the replace function like so:
CKEDITOR.on("instanceReady", function(evt) {
...
CKEDITOR.replace(evt.editor.name, {
toolbarGroups: [
...
],
removeButtons: "..."
})
...
This also doesn't work!
Then I tried pasting the raw config from the configurator into a new file "config2.js" in my ckeditor directory on the server as this page suggests should work, and changing the replace call to:
CKEDITOR.replace(evt.editor.name, {
customConfig: "config2.js"
})
This doesn't work, even if I replace the string with "../ckeditor/config2.js". Looking at the network requests I see it doesn't even try requesting "config2.js" from anywhere.
If it makes any difference, I am starting the editor using CKEDITOR.inline(div) so as far as I know I have to perform the configuration in an event callback.
I also tried calling the replace function from the "instanceCreated" callback - this resulted in an infinite loop / max recursion exceeded error. I also tried it in the "instanceLoaded" event, also without effect.
Update:
I just noticed in the console that when it tries to call replace it throws this error:
Uncaught The editor instance "note1681" is already attached to the provided element.
So it seems I am doing something incorrectly with replace.
I believe it's impossible to hide buttons(change toolbar) after you initialized instance. However, you can recreate you ckeditor with new toolbar.
First, you need to destroy current instance, before creating new one.
CKEDITOR.instances.note1681.destroy();
CKEDITOR.replace('note1681');
For fast switching toolbar, i recommend use custom variable in configuration file.
Add in ckeditor/config.js your toolbar version
editor.my_toolbar = [['Sourcedialog','Cut','Copy']];
Init ckeditor with it
CKEDITOR.replace( 'note1681', { toolbar: my_toolbar })
I am trying to create a programmatic filter. I have a dijit.tree and a dojo gridx using the same source on a jsp. When user clicks the tree node, I want to use the node as a filter and show all rows matching it in the gridx
This is my code I have now for the onClick event of the dijit tree node.
var global=this;
treeWidget.onClick = function(item){
global.grid.filter.setFilter(global.grid.filter.grid.filter.moduleClass.or("test"));
Earlier I asked for a sample expression. I went and tried the code above and seems to
refresh the grid but comes back as No items to display. I do have data that match test and if I do a manual filter I see data returning. What am I missing here.
At https://github.com/oria/gridx/wiki/How-to-filter-Gridx-with-any-condition%3F ( see Filter Expressions)
I was able to accomplish the task using the following code in the diji.tree onClick event.
global.grid.filterBar.applyFilter({
conditions: [{
condition: 'contain',
value: 'test'
}]
});
This is a comment rather than an answer, but I can't post comments yet.
Can you post a working snippet of code? That's not complete, as I don't see your store that you're specifying, etc.
I usually do a myinstancename.grid.body.refresh(); to accomplish a proper refresh.
I have a plugin, that fires off for each pagination click on a page. Mind you, that this pagination is front loaded with all of its data. The plugin that I have fires off to retrieve additional information pages on the current paginated view. So, each click instantiates a new plugin - but the same as before (namespace), so it overrides the previous dataSets that set etc..
Anyways, there might be a point where the .ajax url I am hitting is turned off so that the return will hand something like data.isOff = 1 or data.isOff = 0 , etc.. so that I know that the service is suppressed.
Is there a way for any to persist a value from one instantiation to the next of a plugin and if that value is false, then don't instantiate the new plugin call.. ie.. don't hit the init function. just fail out.
I, of course, can set a global var and to it that way, but curious if there is a way I can do it within the plugin so as to not have any outside vars existing.
I tried to put it in my init function, and set it in my options.. just seems that when I try to instantiate a new plugin, all bets from the previous data is gone.
I am trying to implement jquery mobile autocomplete plugin. The sample usage as mentioned below.
I want to set a Javascript function for the source parameter, and want to make some database queries in that and return information to the page.
How can I do that? Or is there any other way that I can achieve what I want?
$("#searchField").autocomplete({
target: $('#suggestions'),
//Source is either
source: 'data.cfc?method=search&returnformat=json&data=simple'
//or a js object
//autocompleteData = $.parseJSON('[{"value":"1.0","label":"Alabama"},{"value":"2.0","label":"Alaska"}]');
source: autocompleteData
});
You can just pass a function to the source. Though it appears to not be documented, digging through the source code (around line 100) you can see that they can take a function for the source option.
They have a quick example in the comments of the source:
source:function(text,callback) { mydata = [1,2]; callback(mydata); }
It appears to work almost exactly the same as the regular jQuery autocomplete, where the first parameter is the text in the box and you call the second parameter and pass it your filtered data.
I have an app that loads conversations. Each time a conversation is loaded I need to destroy and re init the file uploader.
Per: https://github.com/blueimp/jQuery-File-Upload/wiki/API
I'm trying:
// First destroy existing instance
$('.upload').fileUpload('destroy');
// Init
$('.upload').fileUploadUI({
........
Problem is on first run I get an error: "Uncaught No FileUpload with namespace "file_upload" assigned to this element"
Any ideas on how I can somehow detect if the plugin has been applied and only then destroy? Thansk
You should be able to detect if the plugin has been applied to an element using the "namespace" (as the plugin refers to it), which is the .data() key the plugin uses.
With the current defaultNamespace being 'file_upload', try:
var upload = $('.upload');
if (upload.data('file_upload'))
upload.fileUpload('destroy');
Instead of just:
$('.upload').fileUpload('destroy');
This will mirror the plugin's own test, which you can see around line 920 of the current source.