PDA

View Full Version : Table to Grid / tablegrid passign dateFormat and currency in config?



rakoto
8 Aug 2007, 12:51 AM
I would like to pass some field type format through the config of tablegrid (http://extjs.com/deploy/ext/examples/grid/from-markup.js).

Here a sample of my table :


<table id="accounts" width="100%">
<thead>
<tr>
<th>Due Date</th>
<th>Account Number</th>
<th>Quantity</th>
<th>Amount Due</th>
<th>Email</th>
<th></th>
<th>Liens</th>
</tr>
</thead>
<tbody>
<tr>
<td>23/1/1999</td>
<td>432.23</td>
<td>12</td>
<td>CHF 150.00</td>
<td>[email protected]</td>
<td>quelquechose</td>
<td>http://www.google.ch</td>
</tr>
<tr>
<td>19/5/1999</td>
<td>83849</td>
<td>8</td>
<td>CHF 60.00</td>
<td>[email protected]</td>
<td></td>
<td>/index.cfm</td>
</tr>
...


and the way i use tablegrid with some fields config


<script type="text/javascript">
Ext.onReady(function() {
// create the grid
var grid = new Ext.grid.TableGrid("accounts", {
fields: [
{type:"date", formatDate:"d/m/Y"},
{type:"float"},
{type:"int"},
{},
{}]
});
grid.render();
});
</script>


How can i define the current format of the date in the table who is d/m/Y read it right and render it?
And how can i make work the sorting for the currency column formated has "CHF 235.23"?
Should i do my own render fonction ? Can i pass it through the config?

Thanks for all coming support

8 Aug 2007, 4:03 AM
Formatting the date is in the examples section. Look for the custom renderer portion.

rakoto
15 Aug 2007, 6:55 AM
Thank you djliquidice,

As you invited me i look for my problem in the example section and do some more research forum.

And i found that i can do that :


fields: [
{},
{type:'date', dateFormat: 'd.m.Y'},
....
],
columns: [
{},
{renderer: Ext.util.Format.dateRenderer('d.m.Y')},
....


For the currency column I just do a custom renderer fonction

But now i got another problem that i can't solve by myself (forum resarch api doc all of that i did it~o))

I actually using tablegrid to rapidly pass some existent table in a more friendly rich client look.

So, some of my data have text formatted with tag <a> and then here is the problem sorting on a column who contain data like <a href="page/page.ext?id=2">Link not sorted</a>

:-/ There is my question how should I do to make a column contain link, be sorted well in client-side?

I look for :
sortTypes asText for strips all HTML tags to sort on text only Ext.data.SortTypes, but I wasn't able to make it work.

(appologize for my awfull terrible english :s )

Thanks,

Rako

15 Aug 2007, 6:59 AM
Do you absolutely require the link in your data? You can attach an event for cell or row clicks that can fire an window.open function when clicked or dbl clicked.

rakoto
15 Aug 2007, 10:20 AM
Unfortunately yes, that sure I could attach click event on cell or row, or do a custom render who build the link. But I wont and I can't.
I want build my grid from an existing table. That is the problem I use tablegrid.js (progressively ameliorated) to replace the table widget of dhtmlgoodies. To do a quick transition of existing code.
Fore sure in new dev I will implement grid with an ajax source xml or whatever else. But for right now i want an easy and quick waytodo, even if I m sure i will still use tablegrid in futur for existing table : for accessibility, for easy user back-office implement (spec fonction in RTE)...

I know (not sure:-?) yui DataTable(beta) implement a column type link that handle sorting for tag <a> content. And a column type mail. Same logic but both interested me

Of what I look and what I understand sortTypes : asText was the old way in precedent version of ext to determine the sort type? Isn't it available in ext1.1? I mean in grid, specially with a table.dom source as tablegrid?

rakoto
17 Aug 2007, 12:09 AM
:-/ Nobody can't tell me if it's possible?

Just want sort column who contain for example a link <a href="dontsortMe">sortMe</a>