ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Create unique IDs for every cell

Open musikele opened this issue 11 years ago • 8 comments

Hi, since we have to test our UI with an old-school corporate tool, we need a way to put programmatically a unique ID for every cell of the grid. Is there an option for doing this? Can you recommend other ways to find and refer a single cell of a grid?

musikele avatar Sep 03 '15 10:09 musikele

I'd use a cell template with an id on the div. The id could be a combination of col.uid and some sort of row id that you put in your data, or if you wanted something that you could code easily for in your testing tools, you could use col.name and some sort of unique row id from your data. Would that be sufficient for your purposes?

PaulL1 avatar Sep 03 '15 19:09 PaulL1

Hi, yes, your suggestion can be very useful, at least on the immediate. However I would suggest you another way to do it. When you define a grid in JS we could give it a name, or use some property as identifier, like

$scope.grid.name = 'myGrid';

then every cell could be given an Id like myGrid-row-1-cell-1, myGrid-row-1-cell-2, and so on.

Honestly, I'm not a performance expert, so I don't know if this could impact negatively on the browser.

however, thank you.

musikele avatar Sep 04 '15 07:09 musikele

Hi, after viewing the source code I found that the grid.id is set using the date object (new Date() ). Then, in every cell we have a directive called ui-grid-one-bind-id-grid (uiGridOneBindIdGrid ) that puts the grid.id first and then concatenates other data to it. So, It would be pretty easier for me to set the grid.id as I want (and not dependent on time). Is there a way to do this? I know that there could be problems of consistency if two grids on the same page have the same ID, but in this case it's programmers' responsability to handle this.

musikele avatar Sep 08 '15 13:09 musikele

I have the same problem . I'm trying to test pages that use ui-grid , I need to click on determined rows or cells. Actually the cell's ID that ui-grid provide is useless because it is set at runtime to the millisecond. It might be useful to be able to remove all cell's ID so that developers can provide a unique ID to a DIV surrounding the ui-grid . Then I'd be able to reference (via xpath) any rows or cells starting from the unique ID of DIV . Is possible to remove from ui-grid this useless ID?

Thanks in advance

ciossonno avatar Sep 09 '15 10:09 ciossonno

@musikele @ciossonno setting the id attribute on the div you where you define the grid isn't enough for your needs?

<div id="yourGridID" ui-grid="gridOptions" class="grid"></div>

imbalind avatar Nov 25 '15 09:11 imbalind

Yes, we managed to refer to single cells and rows by using an id on the div AND some css / xpath tricks.

musikele avatar Nov 25 '15 09:11 musikele

Why is this closed? Is it really up to every team using UI Grid to re-implement this completely standard, predictable requirement themselves?

I can understand saying, "this is an open-source project, please bring code along with your request." But how is this not still an open issue?

xentopos avatar Dec 07 '15 20:12 xentopos

Hi dneuer, I closed this because I have solved (well, hacked) in another way to overcome my necessities. However this issue still remains: one cannot simply have a pattern-generated id for every cell (like "myGrid-row-1-cell-1" for example).

What do you believe is better? open a new issue or reopen this one ?

musikele avatar Dec 09 '15 10:12 musikele