|
Rank: Member Groups: Member
Joined: 12/2/2010 Posts: 10
|
I want to use jQuery's .data(), .addClass() and other functions to manipulate an EO grid on the client side. Code such as the following works to achieve what I need.
Code: JavaScript
var cell = myGridID.getSelectedCell();
var domElement = cell.getDOMElement();
$(domElement).data("myKey", "myValue");
The documentation for GridCell.getDOMElement() gives me pause however. It states "this function may return null if the cell is not visible." Is there a method that is guaranteed to return the DOM element of a cell (or row) of a grid control?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
No. You can not do that. The purpose of that function is not for you to manipulate the contents of the Grid cell. It's for some "read only" scenarios. For example, if you wish to get the absolute position of a grid cell, then you can use this function. For anything that can change the Grid's data/state, you must use one of the methods exposed by us.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 12/2/2010 Posts: 10
|
That's disappointing, particularly since the code I've written using getDOMElement() appears to be working perfectly. My goal isn't to modify the actual contents of a cell, but my application is heavy with AJAX and client-side programming. The ability to tag individual cells with bits of data to aid in the processing on the client would be hugely beneficial though I can work around the lack of it.
A bigger issue are my requirements for highlighting and color coding data. The GridCell.overrideStyle() method is proving inadequate for this task. If I call this method to apply a "warning" style to a cell, the cell appears to be losing whatever internal style has been applied. The result is the cell loses its padding and the text is thrown out of alignment with text in other cells. (My style rule contains only a 'color' and 'background-color'.) The jQuery .addClass() and .removeClass() methods don't suffer the same problem. Further, it's very easy to apply and remove multiple classes with the jQuery methods.
Is there other way of tackling this?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
No. You can not use it for that purpose. The reason is there is no fixed one to one relationship between a DOM element and a Grid cell. The Grid manages a list of "virtual items" and at any given time only a portion of that virtual items are mapped to real DOM elements. For example, if the Grid has 10000 items, then it may only create 100 "DOM items". Internally the Grid would be constantly swapping virtual items in and out of DOM items.
GridCell.overrideStyle does literally overrides the whole style. The only way to avoid that is to merge your existing style into the style that you pass to overrideStyle. It does make sense to have features like addClass/removeClass, but that will have to be added through our API because even if you managed to add the class through JQuery, the next time the Grid shuffles virtual items it will be all wiped out.
Thanks!
|
|