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.
Related
In the CKEditor view for authors I need to change links to files so that the session ID of the author gets attached. However in the actual content for normal users the specific user ID is added automatically. Therefore the authors ID must not be saved in the content the author edits with CKEditor, it just has to be there in the view while he edits so that he can see an image for example. On save the 'clean' link without any IDs need to be saved.
In CKEditor 5 there seem to be more possibilities to achieve such a one-way data filtering for example with
Conversions
the Editing Engine generally
the HtmlDataProcessor specifically
However I couldn't find a good example respectively an easy and clean approach to achieve this. (My tries turned out to become quite complicated and didn't work properly...) I'd guess this is a quite common use case so maybe I'm overlooking something. Is there a good solution to this?
Update 1: Example links would be:
"clean link" how it has to be saved but will never work:https://example.com/some-image.png
modified link for specific users in content (and how it has to be modified in ckeditor view for authors as well): https://example.com/some-image.png?sessionId=currentUsersSessionId
Update 2:
While I was working further with CKEditor I came across more things like this which simply are very unpleasant from a developers point of view. And it seems this is by design, since quote from a Contributor 'fredck':
[...] we want to bring the editor out of the "HTML Editor" thing, making it the perfect soluting for "quality content writing".
Implicitly this means, if you are a developer and you have advanced users with advanced use cases (which may be likely the case if you are on Stackoverflow) you are not the target audience and shouldn't use CKEditor in the first place.
You can read more about this for example in the discussion here (also it is about another feature): https://github.com/ckeditor/ckeditor5/issues/592
To modify downloaded links you can write a custom downcast converter, which modifies obtained href.
Here is a working sample which adds the current timestamp to URLs:
https://codepen.io/msamsel/pen/zVMvZN?editors=1010
editor.conversion.for( 'dataDowncast' ).add( dispatcher => {
dispatcher.on(
'attribute:linkHref',
( evt, data, conversionApi ) => {
if ( !conversionApi.consumable.test( data.item, 'attribute:linkHref' ) ) {
return;
}
if ( data.attributeNewValue ) {
data.attributeNewValue += `#time=${ ( new Date() ).getTime() }`;
}
},
{ priority: 'high' }
);
} );
Few words how it works.
There is created listener which reacts on attribute:linkHref changes (it's fired only when data are obtained anyway because it's dataDowncast). Listeners fires with 'high' priority to change URL before the actual Link plugin will create an output. First is checked if the given model element is not consumed, but without consuming it, because we want to preserve native behavior which will process this same element again. The attribute value is extended with a timestamp, what finish this listener. After that, the native behaviour is fired, which has 'normal' priority.
A similar approach was used to implement custom link attributes. More about dispatcher and conversion process might be found here:
https://ckeditor.com/docs/ckeditor5/latest/framework/guides/architecture/editing-engine.html#conversion
https://ckeditor.com/docs/ckeditor5/latest/api/module_engine_conversion_downcastdispatcher-DowncastDispatcher.html
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.
Is it possible to load from server via ajax JQGrid structure(columns) together with data ?
If possible, could you please show an example ?
There's no reason why not, you just ned to do things (asynchronously) in the correct order, something like this (forgive the psuedo code)
var jqGridOptions = {
/* various options here */
}
$.ajax({
url: jqGridStructureUrl
}).success(function(jqGridColumns){
// Add the col model to the other options
jqGridOptions.colModel = jqGridColumns.colModel
jqGridOptions.colNames = jqGridColumns.colNames
// set up the jqGrid
$j("#gridId").jqGrid(jqGridOptions)
})
This will get you part of the way there. I guess you'll also be wanting to load Data via Ajax in which case you can set the "Data" option on the jqGrid settings to a callback function (this is not very well documented) - OR you could fire off TWO ajax calls, one for data and one for structure and then when they're BOTH back munge the two together and instantiate your grid object
You can create jqGrid with all hidden columns. You need create grid with large enough number of columns. The names of the columns (in colModel) can have some generic values like "c1", "c2", "c3" ... The response from the server can contains colModel information together with the data. Inside of beforeProcessing callback you can change colModel and set new column headers. The answer demonstrates setting of column headers dynamically. The code column be simplified by usage setLabel method. Another answer demonstrates how to use setColProp to set the most settings of colModel full dynamically. If you would combine the solution with the usage of setColWidth method which I posted in the answer (see here too) then you could create perfect solution.
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 want to set some params in my swfupload when some links are clicked, so i did something like this:
swfu.setPostParams({"PHPSESSID": swfu.settings.post_params.PHPSESSID, "tutorial": tutorial, "step": nr});
(this is a tutorial editor and i want to know to which step the file belongs to)
The postparams in the DOM is changed, but I can't find them in the $_POST.
Some flash versions have problems with sending stuff in POST, so I added the following line to my swfupload setup:
use_query_string: true,
Now i get the params in $_GET, but no luck there either: i still get the original params.
In IE it works just fine. Any ideas?
I've just had a very similar problem - I had post_params set in the initialization of the swf object and it was there to grab values of hidden inputs on my page.. but the values were always the defaults if I changed them.
I moved that bit of code to an uploadStart handler (fired on "upload_start_handler") - then something like this inside that:
value1 is an input box, value2 is a checkbox - and I'm getting the values with jQuery.
this.swf.setPostParams({
value1: $('#value1').val(),
value2: $('#value2').is(':checked')
});
Works a treat - the values are now populated when the flash uploader hits my back end script!