Hi all,
is there a way to allow the selection of text inside a cell if the AllowUpdate is set to false?
If you have AllowUpdate set to False, you will not be able to select the text within the cells. This is because you can't enter edit mode and therefore you cant select anything because by default, the grid will steal the mouse events to process row activation/selection etc. So, the only way to get around this is to disable some javascript events from the grid. Here is the snippet below.
Add this code to your javascript region (change UltraWebGrid1 to the name of your grid) and you will see that you can select all the text as a normal html table. However, this workaround does come with some limitations. Now there will be no concept of an active row or selected cells/rows. Aside from that, this should give you what you want.
Sorry, I missed a some javascript in the previous post.
I added the onmousedown for the element G_UltraWebGrid1 which is the table element for the grid which contains the rows and columns.
The full javascript should be:
window.onload = function() { document.getElementById('UltraWebGrid1_main').onmouseup = null; document.getElementById('G_UltraWebGrid1').onselectstart = null; document.getElementById('G_UltraWebGrid1').onmouseover = null; document.getElementById('G_UltraWebGrid1').onmousedown = null; }
Hi,
I am trying to implement this same thing but the javascript code cannot seem to find the Webgrid and I am given a javascript error on page load:
document.getelementbyID[...] is null or not an object
I cant seem to do anything to get the correct reference to the webgrid. I have had this same problem before in trying to find a pop window on the client side as well. Is there something I may be doing wrong?
--Stephen
Hello,
If you are not getting the correct object, the problem is most likely because the id's are not correct due to re-Parenting. When the grid is inside of another container(WebPanel, ContentPane, WebTab etc.) the ID will have the parent id prepended on it. So, the grid within a WebPanel will look like this. "WebPanel1_UltraWebGrid1"
So, for the id's for this particular topic, you can check the following:
With the grid Client Side Object:
grid.Element = G_"WebPanel1xUltraWebGrid1"
grid.MainGrid = "WebPanel1xUltraWebGrid1_main"
With our controls, we provide an easy way to obtain the correct ID for the grid and all of our controls. if you use the InitializeLayoutHandler, you can obtain the correct ID and use it globally anywhere else on the page. In the snippet below, I create the GridID global variable and then set it to the gridName parameter passed in by the InitializeLayoutHandler.
var GridID;
function UltraWebGrid1_InitializeLayoutHandler(gridName) {
GridID = gridName;
}
Now that we have a global GridID, we can get the grid clientside object and obtain grid.Element and grid.MainGrid for further use.
var grid = igtbl_getGridById(GridID);
I hope this helps.
hi,
I am using infragistics grid in my application. Where in any browser user cannot select the text in the columns of the Grid with the mouse and copy the text to the clipboard using ctrl+c or copy by right click using mouse. But I need solution to allow user to select text in grid. So can any one give solution for this.
Thanks in advance
Karthick
Hello Karthick,
Which grid are you using, (UltraWebGrid or WebDataGrid)? This is an older post and the javascript code in the previous posts will only work for the older UltraWebGrid control and will not work for the new WebDataGrid control. Please let me know if yoiu are using the UltraWebGrid or the WebDataGrid so the correct approach can be taken.
Steve
Hi Steve,
Thanks for your reply. I am using UltraWebGrid only and I used the javascript code in the previous post its working. Where the user can select the text and copy by right click on the text. But the another problem is that user is not able to select the row. Is there any solution to solve both problems(text selection and row selection ).
Thanks and Regards
Karthick,
The way to get the text selection working is to basically take the mouse events away from the grid handling them and just nulling them out. This way, the grid will no longer handle them. Now, this throws a wrench in the gears of this process because the grid needs to know when it was clicked on to actually select the row. So, the only way would be to get both to work would be to re enable the functionality if you want to actually select records. In my sample, I re-route the grid function calls into my own functions. Then, before you make the call to the grid, there can be some check to see if you want to call the normal grid code(row select) or the nullified one where we can select all the text. In my sample, i check a checkbox.
Please take a look at the sample. Hope it helps.