Rob Rothwell | 11 Apr 13:52
Picon

Adding a graphic to a WebGrid

Can you add a graphic to a cell in a WebGrid?


I am trying to draw attention to, or flag, certain elements in the list and would like to add a column that could contain a small graphic for those items.

Also, could you bold or change the color of the font for only certain items as well?

I know I could do this with a WebTable, but I would have to duplicate what the Grid is doing!

Thanks,

Rob
<div>
<p>Can you add a graphic to a cell in a WebGrid?</p>
<div><br class="webkit-block-placeholder"></div>
<div>I am trying to draw attention to, or flag, certain elements in the list and would like to add a column that could contain a small graphic for those items.</div>
<div><br class="webkit-block-placeholder"></div>
<div>Also, could you bold or change the color of the font for only certain items as well?</div>
<div><br class="webkit-block-placeholder"></div>
<div>I know I could do this with a WebTable, but I would have to duplicate what the Grid is doing!</div>
<div><br class="webkit-block-placeholder"></div>
<div>Thanks,</div>
<div><br class="webkit-block-placeholder"></div>
<div>Rob</div>
</div>
Janko Mivšek | 11 Apr 21:45
Picon

Re: Adding a graphic to a WebGrid

HiRob,

Rob Rothwell wrote:
> Can you add a graphic to a cell in a WebGrid?
> 
> I am trying to draw attention to, or flag, certain elements in the list 
> and would like to add a column that could contain a small graphic for 
> those items.
> 
> Also, could you bold or change the color of the font for only certain 
> items as well?
> 
> I know I could do this with a WebTable, but I would have to duplicate 
> what the Grid is doing!

You can prepare and put in a cell anything you want with:

	aGrid column: aNumber addBlock: aBlock

Block is called with a current row object as argument and it must return 
a valid WebElement.

For instance let we put an arrow from existing method images in first 
column:

   	aGrid column: 1
	  addBlock: [:rowObject | WebImage gif: #arrowCircledRedGif ]

This can also be used for coloring cell content appropriately. But for 
coloring entire row you have some prepared methods too:

	rowBlueIfTrue: [:rowObject | "some boolean expresion"]
	rowGreenIfTrue:, rowRedIfTrue:, rowYellowIfTrue: rowGrayIfTrue:
	rowBoldIfTrue: "for whole row to be bold"

Best regards
Janko

--

-- 
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
Aida <at> aidaweb.si
http://lists.aidaweb.si/mailman/listinfo/aida
Rob Rothwell | 11 Apr 22:29
Picon

Re: Adding a graphic to a WebGrid

On Fri, Apr 11, 2008 at 3:45 PM, Janko Mivšek <janko.mivsek <at> eranova.si> wrote:
You can prepare and put in a cell anything you want with:

       aGrid column: aNumber addBlock: aBlock

Block is called with a current row object as argument and it must return a valid WebElement.

This is just what I was looking for!  Is there anything you haven't thought of yet?

For instance let we put an arrow from existing method images in first column:

       aGrid column: 1
         addBlock: [:rowObject | WebImage gif: #arrowCircledRedGif ]

That will do it!

This can also be used for coloring cell content appropriately. But for coloring entire row you have some prepared methods too:

       rowBlueIfTrue: [:rowObject | "some boolean expresion"]
       rowGreenIfTrue:, rowRedIfTrue:, rowYellowIfTrue: rowGrayIfTrue:
       rowBoldIfTrue: "for whole row to be bold"

Thank you...the WebGrid is truly useful.  What did you think of my post last weekend about handling nil values in a sortable column?  I just subclassed WebGrid for now, but it's nice to have the nil values sort without causing a DNU...

Thanks again.  

Rob

P.S.  I have registered for Smalltalk Solutions; I'll take good notes and share what I pick up!


 


Best regards
Janko


--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si

<div>
<div class="gmail_quote">On Fri, Apr 11, 2008 at 3:45 PM, Janko Miv&scaron;ek &lt;<a href="mailto:janko.mivsek <at> eranova.si">janko.mivsek <at> eranova.si</a>&gt; wrote:<br><blockquote class="gmail_quote">
You can prepare and put in a cell anything you want with:<br><br>
 &nbsp; &nbsp; &nbsp; &nbsp;aGrid column: aNumber addBlock: aBlock<br><br>
Block is called with a current row object as argument and it must return a valid WebElement.</blockquote>
<div><br class="webkit-block-placeholder"></div>
<div>This is just what I was looking for! &nbsp;Is there anything you haven't thought of yet?</div>
<div><br class="webkit-block-placeholder"></div>
<blockquote class="gmail_quote">For instance let we put an arrow from existing method images in first column:<br><br>
 &nbsp; &nbsp; &nbsp; &nbsp;aGrid column: 1<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;addBlock: [:rowObject | WebImage gif: #arrowCircledRedGif ]</blockquote>
<div><br class="webkit-block-placeholder"></div>
<div>That will do it!</div>
<div><br class="webkit-block-placeholder"></div>
<blockquote class="gmail_quote">
This can also be used for coloring cell content appropriately. But for coloring entire row you have some prepared methods too:<br><br>
 &nbsp; &nbsp; &nbsp; &nbsp;rowBlueIfTrue: [:rowObject | "some boolean expresion"]<br>
 &nbsp; &nbsp; &nbsp; &nbsp;rowGreenIfTrue:, rowRedIfTrue:, rowYellowIfTrue: rowGrayIfTrue:<br>
 &nbsp; &nbsp; &nbsp; &nbsp;rowBoldIfTrue: "for whole row to be bold"</blockquote>
<div><br class="webkit-block-placeholder"></div>
<div>Thank you...the WebGrid is truly useful. &nbsp;What did you think of my post last weekend about handling nil values in a sortable column? &nbsp;I just subclassed WebGrid for now, but it's nice to have the nil values sort without causing a DNU...</div>
<div><br class="webkit-block-placeholder"></div>
<div>Thanks again. &nbsp;</div>
<div><br class="webkit-block-placeholder"></div>
<div>Rob</div>
<div><br class="webkit-block-placeholder"></div>
<div>P.S. &nbsp;I have registered for Smalltalk Solutions; I'll take good notes and share what I pick up!</div>
<div><br class="webkit-block-placeholder"></div>
<div><br class="webkit-block-placeholder"></div>
<div>&nbsp;</div>
<blockquote class="gmail_quote">
<br><br>
Best regards<br>
Janko<br>
<br><br>
-- <br>
Janko Miv&scaron;ek<br>
AIDA/Web<br>
Smalltalk Web Application Server<br><a href="http://www.aidaweb.si" target="_blank">http://www.aidaweb.si</a><br>
</blockquote>
</div>
<br>
</div>
Janko Mivšek | 11 Apr 22:37
Picon

Re: Adding a graphic to a WebGrid

Rob Rothwell wrote:

> This is just what I was looking for!  Is there anything you haven't 
> thought of yet?

Answer is simple: when I needed something useful to simply my work, I 
just made it. So, you can understand Aida as an act of laziness :)

> Thank you...the WebGrid is truly useful.  What did you think of my post 
> last weekend about handling nil values in a sortable column?  I just 
> subclassed WebGrid for now, but it's nice to have the nil values sort 
> without causing a DNU...

I checked your patch for introduction into WebGrid. It seems soon.

> P.S.  I have registered for Smalltalk Solutions; I'll take good notes 
> and share what I pick up!

Yes, please do that. I'm already inpatient!

Janko

--

-- 
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
Aida <at> aidaweb.si
http://lists.aidaweb.si/mailman/listinfo/aida

Gmane