I have this bit of code that I use to edit input fields. The example I was given is something like:
editCellStarted: function ( evt, ui ) { var input = $( "input.ui-igedit-field" );
... do stuff.
I ran in to an issue when I use a pop out feature we created to copy the entire div and put it in to a new window. The problem is that the new window does not understand the css "input.ui-igedit-field" . So input is null. Unfortunately I dont know enough about that line to make this work. I'm guessing it makes a Jquery object form the css on a cell. Since my new pop up page does not have access to a "input.ui-igedit-field" I need to make this code work another way.
full code:
editCellStarted: function ( evt, ui ) { var input = $( "input.ui-igedit-field" ); setTimeout( function () { //if we have a keypress in the buffer replace the text otherwise move the cursor. if ( INSTANCE.cellSelectionEditModeAscii != null ) { input.val( INSTANCE.cellSelectionEditModeAscii ) } else { input.val( INSTANCE.oldEditValue ); input.prop( "selectionStart", input.val().length ).select(); } INSTANCE.cellSelectionEditModeAscii = null; document.getElementById( "myContentValue" + INSTANCE.ID ).value = input.val(); }, 150 ); },
Originally it was not (wrong font size), I posted this somewhere on this board. Then I did something (I think it was an update?) that fixed it. Now its a perfect match.
Hello,
I wanted to let you know that I am currently creating isolated sample based on the provided code snipped. Tomorrow I will contact you with my findings.
Meanwhile, could you please explain me something related to the igGrid, after you append the div that hold the igGrid to the new window, is it showing properly. By saying this I mean, with all proper styles, events etc?
commented on wrong post.
I guess you could take any sample and add this slimmed down code.
function popOut ( win ) { var linkrels = document.getElementsByTagName( 'link' ); var strWindowFeatures = "menubar=yes,location=no,resizable=no,scrollbars=no,status=yes,width=500,height=400"; newWindow = window.open( "http://localhost:62578/blank/index2", "", strWindowFeatures, false ); newWindow.onload = function () { for ( var i = 0 ; i < linkrels.length; i++ ) { //copy in styles. if ( linkrels[i].rel && linkrels[i].rel.toLowerCase() == 'stylesheet' ) { var thestyle = document.createElement( 'link' ); var attrib = linkrels[i].attributes; for ( var j = 0 ; j < attrib.length; j++ ) { thestyle.setAttribute( attrib[j].nodeName, attrib[j].value ); } this.document.documentElement.appendChild( thestyle ); } } popWin = this.document.body.appendChild( win );// copy in div $( popWin ).width( this.innerWidth + 35 ); $( popWin ).height( this.innerHeight ); }; }
then make sure to use the editCellStarted and add the line
var input = $( "input.ui-igedit-field" );
You should get that error on the new window but not the old window.
From where you try do get the input from the main window or from the newly opened one?
I do a window.open and copy the div holding the grid in to it. This is the function that creates the new window. It does not show all that is going on but should give you a better idea. After this, most all aspects of the grid remain, events, styles, ect... Though then I click to edit a cell it runs the code I posted earlier from the editCellStarted and fails because it cant find the selector on the page.
win is the div that hold the igrid.dsWindow is a pointer to the class
igniteui.prototype.popOut = function ( win, dsWindow ) { $( win ).unbind( 'mousedown' );//clear existing. $( win ).mousedown( function ( e ) {_currentWindowPinned = dsWindow.window } )//needs to be fired only wen not clicking buttons, buttons stop the event bubble. var linkrels = document.getElementsByTagName( 'link' ); var strWindowFeatures = "menubar=yes,location=no,resizable=no,scrollbars=no,status=yes,width=500,height=400"; newWindow = window.open( "http://localhost:62578/blank/index2", "", strWindowFeatures, false ); newWindow.onload = function () { for ( var i = 0 ; i < linkrels.length; i++ ) { //copy in styles. if ( linkrels[i].rel && linkrels[i].rel.toLowerCase() == 'stylesheet' ) { var thestyle = document.createElement( 'link' ); var attrib = linkrels[i].attributes; for ( var j = 0 ; j < attrib.length; j++ ) { thestyle.setAttribute( attrib[j].nodeName, attrib[j].value ); } this.document.documentElement.appendChild( thestyle ); } } this.focus( true ); popWin = this.document.body.appendChild( win );// copy in div popWin.style.top = 0; popWin.style.left = 0; popWin.id = this.POPid++; //assign an id > 100 dsWindow.window.setPopOut( true ); $( popWin ).width( this.innerWidth + 35 ); $( popWin ).height( this.innerHeight ); this.onresize = function () { $( popWin ).width( this.innerWidth + 35 ); $( popWin ).height( this.innerHeight ); dsWindow.window.updateWindowSize( $( popWin ).width(), $( popWin ).height(), false );//update grid display } this.document.title = dsWindow.window.getWindowName(); $( this.document ).bind( "contextmenu", _iUI.rClickFunction ) }; }