<g:Grid>
<g:row>
<g:customCell>
<g:HTMLPanel styleName="{style.loginPrompt}">
<div>
<ui:msg description="LoginPrompt">Please <b>Log In</b></ui:msg>
</div>
</g:HTMLPanel>
</g:customCell>
</g:row>
...
I want that my cell text will be in second cell like in java:
Grid g = new Grid(5, 5);
g.setText(0, 1, "asdf");
If you want 5 rows and 5 columns, I think you have to define them all in the UiBinder using the appropriate number of g:row and g:cell (or g:customCell). There's no equivalent to setText but you can do the equivalent of setHTML by using a g:cell (and g:customCell is equivalent to setWidget).
<g:Grid>
<g:row>
<g:customCell><!-- whatever --></g:customCell>
<g:cell>asdf</g:cell>
<!-- continue here for 5 rows, 5 cells per row -->
Related
I have a flex table in GWT , it has 3 rows . Now I want to draw a line / separator after every row .(just separator between rows, Not for column)
can i acheive this ..
here's the current screen
You can see 3 rows , just need a clean and nice line between them
A FlexTable is rendered as just a <table> with their cells being simple <td>s. So in your CSS you can include something like this:
.tableWithRowsDelimiter td {
border-bottom: 1px solid #c9c9c9;
}
And then assign the tableWithRowsDelimiter style to your FlexTable, via ui.xml:
<g:FlexTable ui:field="yourFlexTable" class="tableWithRowsDelimiter"/>
Or in your Java code:
yourFlexTable.setStyleName("tableWithRowsDelimiter");
I've got a trouble selecting divs following specific title in code:
<div>
<h2>Section 1</h2>
<div>Item 1</div>
<div>Item 2</div>
<h2>Section 2</h2>
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
</div>
I was trying to get the nodes using preceding-sibling somehow like this:
//div/div[preceding-sibling::h2[1][position()=1]]
I need all divs which have the NEAREST preceding h2 sibling on position 1, but I'm still getting all 5 items.
Can you tell me what am I doing wrong?
Example output with position 1 (section 1):
<div>Item 1</div>
<div>Item 2</div>
Example output with position 2 (section 2):
<div>Item 3</div>
<div>Item 4</div>
<div>Item 5</div>
This can be a tricky thing to do, but one approach you can use is count():
//div/div[count(preceding-sibling::h2) = 1]
The reason your attempt with position() didn't work is that position() is evaluated relative to the current selection. With preceding-sibling::h2[1][position()=1], you are selecting the nearest h2 and then selecting the first node in that set.
I have a string:
<h2>header 1</h2>
<p>paragraph 1</p>
<h2>header 2</h2>
<h3>siausjfks</h3>
....(anything not containing h2 and p tags)
<div><h2>header 3</h2> jasgfks</div>
.... (anything not containing h2 and p tags)
<p>paragraph 2</p>
Now i want to have array
element 1 = header 1
element 2 = paragraph 1
element 3 = header 2
element 4 = header 3
element 5 = paragraph 2
Is there a way to accomplish this using simple HTML DOM?
Thanks :)
UPDATE: This is actually to find 2 tags simultaneously, how about finding 3, 4 and more tags?
<div id="rotator">
<p id="1">Some Text 1</p>
<p id="1">Some Text 2</p>
<p id="1">Some Text 3</p>
</div>
They are presented in a row. All I want is automatically cycle the three text by toggling opacity, ie. at first text 1 is opacity 1, and test 2 and 3 are opacity .5. Then after 5 seconds or so, text 2 is opacity 1, and text 1 and three are opacity .5... so on in a cycle.
Can someone give me a hint/direction on how to do this in jquery please. Thank you in advance.
I have the fallowing code :
<table id="table1" class="class1">
<thead>...<thead>
<tbody>
<tr id="1">
<td class>cell1</td>
<td class>cell2</td>
<td class>cell3</td>
<td class>cell4</td>
</tr>
<tr id="2">
....
<\tr>
...
I need to go over all the rows and check if cell number 3 has "cell3" as text . (for starters)
then after ive found it i need to keep checking the rows for a different string in cell number 3
I've tried:
string="cell3"
rows=browser.table.rows
rows.each {|tr|
if tr.td( :index =>2).text ==string
puts " Found #{string}"
string="cellK"
end
}
Im doing it in a loop since there are several strings i need to find.
But im getting the fallowing error :
unable to locate element, using {:index=>2, :tag_name=>"td"}
Any advice ?
How can i get the text of a td?
and why cant i find td by index ?
I am guessing that the problem is the header row in the thead. The table head is probably something like:
<thead>
<tr id="0">
<th class>heading1</th>
<th class>heading2</th>
<th class>heading3</th>
<th class>heading4</th>
</tr>
<thead>
Notice that there is a tr. table.rows will therefore include the header row. Also notice that it is using th instead of td cells. It is likely here that watir cannot find the td with index 2, because there are no tds at all in this row.
Assuming this is the problem, you have a couple solutions.
Solution 1 - Make th and td equivalent by using cells
Inside the loop, use cell instead of td:
rows.each {|tr|
if tr.cell( :index =>2).text == string #Note the change here
puts " Found #{string}"
string="cellK"
end
}
Table#cell matches td and th cells. This means that cell(:index, 2) would match the 3rd td or th in the row. When watir checks the header row, it will now find a value.
Solution 2 - Ignore the thead
When getting the rows to check, confine the rows collection to only include rows in the tbody:
rows = browser.table.tbody.rows
This would then ignore the riws in the thead that are causing the problem.