Johnhe
October 23, 2015, 5:47pm
#1
when i have a cell and it’s value is “abc123456ab12”
and when i use my mouse select any characters ,how can i show the popup on the “selected characters”,and how can i get the value of “selected characters”
i upload a pic,how can i get the selected characters value,and same show the popup…
Johnhe
November 10, 2015, 8:43am
#3
i have finish this function.
(function($){
$.fn.selection = function(){
var s,e,range,stored_range;
if(this[0].selectionStart == undefined){
var selection=document.selection;
if (this[0].tagName.toLowerCase() != "textarea") {
var val = this.val();
range = selection.createRange().duplicate();
range.moveEnd("character", val.length);
s = (range.text == "" ? val.length:val.lastIndexOf(range.text));
range = selection.createRange().duplicate();
range.moveStart("character", -val.length);
e = range.text.length;
}else {
range = selection.createRange(),
stored_range = range.duplicate();
stored_range.moveToElementText(this[0]);
stored_range.setEndPoint('EndToEnd', range);
s = stored_range.text.length - range.text.length;
e = s + range.text.length;
}
}else{
s=this[0].selectionStart,
e=this[0].selectionEnd;
}
var te=this[0].value.substring(s,e);
return {start:s,end:e,text:te}
};
})(jQuery);
function cellValSelectionAction(stage, rowId, cellInd){
if (stage == 0) {
} else if (stage == 1) {
if (resultGrid.editor && resultGrid.editor.obj) {
var grideditor = resultGrid.editor.obj;
var cellSelectVal = '';
jQuery(grideditor).select(function(){
hidePopup();
cellSelectVal = jQuery(grideditor).selection().text;
console.log(cellSelectVal);
if(cellSelectVal.length>0){
showPopup(grideditor,cellSelectVal);
}
});
}
}else if(stage == 2){
hidePopup();
}
}