jqGrid 4.1.0 issue with icon hover when inline edit - jqgrid

In previous version when inline editing all looking good:
But in new version it is looking like that (i put read border over):
How to fix that?
I am using jQuery 1.6.1, jQueryUI 1.8.13
I also have using the latest jqGrid css file

The reason seems to me the wrong hover effects included in the jqGrid 4.1.0 on the <span> element with the save and cancel icons:
onmouseover=jQuery(this).addClass('ui-state-hover');
onmouseout=jQuery(this).removeClass('ui-state-hover');
see the source code of jquery.fmatter.js.
If I correct understand the problem the adding of 'ui-state-hover' class overwrites the background-position to 50% 50%, so the icons for the disk (ui-icon-disk) or the cancel icon (ui-icon-cancel) will not more displayed. Instead of that the middle of the background image are displayed.
So I suggest just remove the hover effects inside of loadComplete:
loadComplete: function() {
$("div.ui-inline-save > span.ui-icon-disk, div.ui-inline-cancel > span.ui-icon-cancel").each(function() {
this.onmouseover = null;
this.onmouseout = null;
});
}
See the demo.
UPDATED:: I found a better way to fix the problem. First we can defive the functions iconHoverFixed and iconNotHoverFixed as following
var iconHoverFixed = function(e) {
jQuery(this).addClass('ui-state-hover');
jQuery('span',this).removeClass('ui-state-hover');
},
iconNotHoverFixed = function(e) {
jQuery(this).removeClass('ui-state-hover');
};
and then we can fix the hovering problem so:
loadComplete: function() {
$("div.ui-inline-save, div.ui-inline-cancel").each(function() {
this.onmouseover = iconHoverFixed;
this.onmouseout = iconNotHoverFixed;
});
}
See the new demo here or here.

Looks like you need to update the jquerygrid css and the images folder the image is build from an offset inside an image (Sprite) http://www.trirand.com/blog/jqgrid/themes/redmond/images/ui-icons_6da8d5_256x240.png
and in you case it doesn't find the right place

Related

How to change group of CSS items in jqGrid

I want to change group of CSS items in jqGrid. Documentation is saying
Of course if we want to change not only one CSS item from a group, but two or more we can use jQuery extend to do this:
var my_col_definition = {
icon_move : 'ui-icon-arrow-1',
icon_menu : "ui-icon-pencil"
}
$.extend( $.jgrid.styleUI.jQueryUI.colmenu , my_col_definition );
And this is working partially. But I want to override all icons in my Bootstrap with next code:
$.extend($.jgrid.styleUI.Bootstrap, {
common: {
icon_base: "fa"
},
inlinedit: {
icon_edit_nav: "fa-edit"
},
navigator: {
icon_edit_nav: "fa-edit"
},
// ...
});
and my grid stops working and does not respond to any commands. There are no errors in console.
Do anybody know how to fix the problem in an elegant way and do not override every group separately?
It is unknown which versions of Guriddo jqGrid and Bootstrap are used.
I see you try to use the fontAwesome.
With the last release you can use fontAwesome with ths following settings:
<script>
$.jgrid.defaults.styleUI = 'Bootstrap4';
$.jgrid.defaults.iconSet = "fontAwesome";
</script>
And point to the needed css files as described in this documentation
You can change the icons the way you do in your code without problems - I have tested this and it works.
In any case, please prepare a simple demo which reproduces the problem, so that we can look into it.

syncronized scroll does not work in div based ckeditor

Basically i have 2 instances of ckeditor on a single page. One on the left and another in the right side of the page.
The left editor uses a div rather than traditional iframe. I've done this by removing the iframe plugin and including the div editing area plugin.
The right editor loads in an iframe and but is also div based(i can use the iframe editor as well on the right if required, not an issue).
Now if the cursor/focus is on the right editor's content area then the left editor should scroll along with it. I've tried to use the code as provied by Reinmar in below url but it seems to work only with editors based on iframe on both sides. Also please note that i'm using jquery adapter for initializing the editors.
CKEDITOR how to Identify scroll event
I initialized the editor on left as below:
var editor_left = $( '#editor_left' ).ckeditor();
And below is my code for the right editor:-
var editor_right = $( '#editor_right' ).ckeditor();
editor_right.editor.on( 'contentDom', function() {
var editable = editor_right.editor.editable();
editable.attachListener( editable.getDocument(), 'scroll', function() {
alert('scroll detected');
parent.$('#left_editor_content_area').scrollTop($(this).scrollTop())
});
});
If i use the iframe based editor on the right then i'm able to get the "scroll detected" alert. But the scrollTop() function still does not work as expected
Any help will be appreciated.
The code that you mentioned is right. You got to update scrollTop property of the div-based editable with the scroll position of the window inside the iframe-based editor (JSFiddle).
var editor_div = CKEDITOR.replace( 'editor_div', {
extraPlugins: 'divarea'
} );
CKEDITOR.replace( 'editor_iframe', {
on: {
contentDom: function() {
var editable = this.editable(),
win = this.document.getWindow(),
doc = editable.getDocument();
editable.attachListener( doc, 'scroll', function( evt ) {
// Get scroll position of iframe-based editor.
var scroll = win.getScrollPosition();
// Update scroll position in the div-based editor.
editor_div.editable().$.scrollTop = scroll.y;
} );
}
}
} );

Is there an example or more documentation for how to do visualize the grid?

I am having a little trouble figuring out how to turn on the grid visualization: https://github.com/Team-Sass/Singularity/wiki/Creating-Grids#visualizing-your-grids.
Can someone point me to more help or share an example?
This can be found deep within the singularitygs Ruby gem:
Grid Overlay & Background
There are three ways you can display a grid:
Manually apply the background to the element
.container {
#include background-grid;
}
Add a switch to toggle an overlay -
#include grid-overlay('.container');
Toggle grid with JavaScript
#include grid-toggle in an SCSS * { … } or html { … } element.
Add [data-development-grid="show"] to item you want grid applied to
Add "grid.js" to the HTML head
The first will apply a grid background to your container calculated using your
grid settings, media breakpoints etc.
The second will add a switch to your page which allows you to view a grid
overlay over your container (or if none is provided) by hovering over
the switch. if you need your mouse for other things you can toggle the overlay
on permanently by inspecting and checking :hover in your styles panel.
The third will allow you to toggle your background grid on and off by pressing the 'g' on your keyboard.
I couldn't get grid.js to work, so I rewrote it using a bit of jQuery. Here is my version:
// A working jQuery/javascript script for the hide/show grid
$(document).ready(function() {
$('html').keypress(function(event) {
if (event.which === 103) {
var wrap = document.getElementById("wrap");
var dev = wrap.getAttribute('data-development-grid');
if (dev === null || dev === 'hide') {
wrap.setAttribute('data-development-grid', 'show');
}
else {
wrap.setAttribute('data-development-grid', 'hide');
}
}
});
});
I find method 2 is rather neat. You get a symbol of 4 vertical bars in the bottom left of your webpage and the grid appears with mouseover. Similar to Susy's Home Page

Slickgrid - Lost focus to end edit

When editing my grid, if I click outside the grid, the box I was editing is still editable. How do I get the edited cell to "complete" the edit when it looses focus?
The following code will save the current edit.
Slick.GlobalEditorLock.commitCurrentEdit();
You'll need to place this inside an event handler that you think should trigger the save. For example, if you're using the sample text editor plugin, I believe an editor-text CSS class is added to the input field that's created when you're editing a cell so something like this should work:
$('#myGrid').on('blur', 'input.editor-text', function() {
Slick.GlobalEditorLock.commitCurrentEdit();
});
I found that I needed to wrap clav's handler in a timeout:
$("#myGrid").on('blur', 'input.editor-text', function() {
window.setTimeout(function() {
if (Slick.GlobalEditorLock.isActive())
Slick.GlobalEditorLock.commitCurrentEdit();
});
});
to avoid errors like:
Uncaught NotFoundError: An attempt was made to reference a Node in a context where it does not exist.
when using the keyboard to navigate. Presumably the new blur handler fires before SlickGrid can do its own handling and this causes problems.
Unfortunately, probably due to differences in event processing, Grame's version breaks keyboard navigation in chrome.
To fix this, I added another check to only commit the edit, if the newly focused element is not another editor element within the grid (as the result of keyboard navigation):
$('#grid').on('blur.editorFocusLost', 'input.editor-text', function() {
window.setTimeout(function() {
var focusedEditor = $("#grid :focus");
if (focusedEditor.length == 0 && Slick.GlobalEditorLock.isActive()) {
Slick.GlobalEditorLock.commitCurrentEdit();
}
});
});
This seems to work in current versions of firefox, chrome and ie.

How to make full CKEditor re-initialization?

Please help me - I need to make full re-initialization of CKeditor. I don't want to make re-initialization of instances of CKeditor, but I want fully reload it. Is there any way to implement it?
I tried to made next:
delete window.CKEDITOR;
and then:
//clear for old sources
$('script[src*="/includes/contentEditor/ckeditor/"]').each(function() {
$(this).remove();
});
$('link[href*="/includes/contentEditor/ckeditor/"]').each(function() {
$(this).remove();
});
//load CKeditor again
contentEditor.loadjscssfile('/includes/contentEditor/ckeditor/ckeditor.js', 'js');
contentEditor.loadjscssfile('/includes/contentEditor/ckeditor/adapters/jquery.js', 'js');
My method loads editor but some plugins does not work after reloading. Thanks for any help!
I have plugins and I don't need to fully reinitialize CKEditor either, just instances, are you doing it properly?
To remove my instance (my textarea is referenced by ID txt_postMsg):
$('#btn_cancelPost').click(function(){
CKEDITOR.remove(CKEDITOR.instances.txt_postMsg);
$('#txt_postMsg').remove();
$('#cke_txt_postMsg').remove();
});
Then I re-create the textarea, and after a 50ms timeout I call the constructor with the textarea again, plugins reload fine. We have some pretty complex plugins for flash/image editing so maybe there's an issue with your plugin?
My version:
$$("textarea._cke").each(function(Z) {
if (typeof(CKEDITOR.instances[Z.id]) == 'undefined') {
CKEDITOR.replace(Z.id, { customConfig : "yourconfig.js"});
} else {
CKEDITOR.instances[Z.id].destroy(true);
CKEDITOR.replace(Z.id, { customConfig : "yourconfig.js"});
}
});
try something like
for(var instanceName in CKEDITOR.instances)
CKEDITOR.remove(CKEDITOR.instances[instanceName]);
CKEDITOR.replaceAll();
AlfonsoML
I use CKeditor for dynamically edit different part of site. When I click on some area of the site it shows popup with CKeditor with content of this area above this area. When I save it I destroy instance of this editor, but if while editing I use link plugin CKeditor can't show editor without page refreshing. Chrome says - Uncaught TypeError: Cannot call method 'split' of undefined, Mozilla - x.config.skin is undefined(I try to set config.skin and it show another error - z is undefined).
I hope the full re-init can help.
P.S. Sorry I can find how to answer on your comment...
I've been looking for a way to re-initialize the editor and the only solution that I end up is to delete the instance and create a new ID.
Here's my code.
var editor = 'myeditor'
var instance = CKEDITOR.instances[editor];
if(typeof instance != 'undefined')
{
instance.destroy();
$(".cke_editor_" + editor).remove();
//make a new id
editor = (Math.random().toString(36).substr(2, 10););
}
CKEDITOR.replace(editor,
{
}
It's not perfect but it works.
Hope this helps.
This is my solution:
var editor = CKEDITOR.instances[your_ckeditor_id];
editor.mode = 'source';
editor.setMode('wysiwyg');
OR
var editor = CKEDITOR.instances[your_ckeditor_id];
editor.setData(editor.getData());

Resources