Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Alexandre Lerat on Dec 10, 2008 01:26
open dhtmlx forum
Grid not refreshing after loading data

Hi,

I'm having a problem to refresh a grid after loading data from javascript String.

Here is my grid declaration from HTML table :
<table onbeforeinit="createJSString();" lightnavigation="true" imgpath="../images/grid/" id="some_table">
    <tr>
        <td type="dhxCalendarA" sort="na" width="75" align="center" format="%d/%m/%Y">
            Mission begin date <img src='../images/grid/etoile.png'/>
        </td>
        <td type="time" sort="na" width="75" align="center">
            Begin hour<img src='../images/grid/etoile.png'/>
        </td>
        <td type="dhxCalendarA" sort="na" width="75" align="center" format="%d/%m/%Y">
            Mission end date <img src='../images/grid/etoile.png'/>
        </td>
        <td type="time" sort="na" width="75" align="center">
            End hour (hh:mm) <img src='../images/grid/etoile.png'/>
        </td>
        <td type="coro" sort="na" width="50" align="center">
            Country <img src='../images/grid/etoile.png'/>
        </td>
        <td type="ro" sort="na" width="60" align="center">
            Group <img src='../images/grid/etoile.png'/>
        </td>
        <td type="ro" sort="na" width="70" align="center">
            Amount / day<img src='../images/grid/etoile.png'/>
        </td>
        <td type="edn" sort="na" width="70" align="center">
            Nb of day<img src='../images/grid/etoile.png'/>
        </td>
        <td type="ron[=c6*c7]" sort="na" width="60" align="center">Total(€)</column>
        <td type="doubleimglink[../images/grid/add.png^javascript:addRow()^_self|../images/grid/delete.png^javascript:deleteRow()^_self]" sort="na" align="center" width="50"></td>
    </tr>
</table>
<script>
    mygrid = new dhtmlXGridFromTable("some_table");
    mygrid.setSkin("SkinPerso");
    mygrid.enableMultiselect(false);
    mygrid.setSerializationLevel(false, true);
    mygrid.attachEvent("onCellChanged", doOnCellChanged);
    mygrid.enableResizing("false, false");
    mygrid.submitOnlyChanged(false);
    mygrid.init();
    mygrid.attachFooter(",#cspan,#cspan,#cspan,#cspan,montant total (€),#cspan,#cspan,{#stat_total}", ",,,,,text-align:right,,,text-align:center");
    mygrid.enableAutoHeight(true);
    mygrid.enableAutoWidth(true);
    mygrid.preventIECaching("true")
    combo = mygrid.getCombo(4);
    combo.put("1", "Unité européenne avant élargissement");
    combo.put("2", "Suisse");
    combo.put("3", "DOM TOM");
    combo.put("4", "Pays d’Europe hors groupe 1");
    combo.put("5", "Afrique du Nord");
    combo.put("6", "Moyen Orient");
    combo.put("7", "Canada");
    combo.put("8", "USA");
    combo.put("9", "Australie");
    combo.put("10", "Hong-Kong");
    combo.put("11", "Singapour");
    combo.put("12", "Taïwan");
    combo.put("13", "Amérique Centrale et du Sud");
    combo.put("14", "Caraïbes");
    combo.put("15", "Océanie");
    combo.put("16", "Afrique Noire");
    combo.put("17", "Asie (hors groupe 2)");
    combo.put("18", "Turquie");
    combo.put("19", "Pays aux conditions particulièrement difficiles");
    combo.save();
    mygrid.loadXMLString(values);
</script>

As you can see column "Total" is math formula of column 6 and 7 --> The total column is correctly updated when the string "values" contains no value --> I can add, delete lines the column is correctly updated.

My problem appears when i load "values" which contains some rows : For example :

<?xml version="1.0"?>
<rows>
<row id='row1'>
<cell>09/12/2008</cell>
<cell>08:00</cell>
<cell>13/12/2008</cell>
<cell>18:00</cell>
<cell>9</cell>
<cell>Groupe 2</cell>
<cell>23</cell>
<cell>4</cell>
<cell>92</cell>
<cell>../images/grid/add.png^javascript:addRow()^_self|../images/grid/delete.png^javascript:deleteRow()^_self</cell>
</row>
</rows>

When i change values in column 6 or 7 the total column isn't calculated. Why ?

I give you samples here : http://zepload.com/images/1228901137_GoodCalculation.png
http://zepload.com/images/1228901162_BadCalculation.png
Answer posted by Support on Dec 10, 2008 03:13
>>When i change values in column 6 or 7 the total column isn't calculated. Why ? 
Formula used for column will be applied only if related cell is empty. In your case it already has some predefined value ( 92 ) , so grid not uses formula but constant value from XML
If you need to have this column auto-calculated, not specify its value in XML
<cell></cell>
or specify it as formula
<cell>=c6*c7</cell>
Answer posted by Support on Dec 10, 2008 03:13
Basically - value in XML override formula defined for column.
Answer posted on Dec 10, 2008 05:34
Thanks for your quick answer I try it and i come back to you

Answer posted by Alexandre Lerat on Dec 10, 2008 07:49
I have to store XML in database so can i delete total column value from XML using serialisation method ???

For example, i should see 92 in cell but no value in xml. Can i do that ?

<?xml version="1.0"?>
<rows>
<row id='row1'>
<cell>09/12/2008</cell>
<cell>08:00</cell>
<cell>13/12/2008</cell>
<cell>18:00</cell>
<cell>9</cell>
<cell>Groupe 2</cell>
<cell>23</cell>
<cell>4</cell>
<cell></cell>
<cell>../images/grid/add.png^javascript:addRow()^_self|../images/grid/delete.png^javascript:deleteRow()^_self</cell>
</row>
</rows>
Answer posted by Support on Dec 10, 2008 09:52
Can be done by adding next line before grid's init

eXcell_math.prototype.getMathValue=function(){
 return "";
}

and next line as part of grid's init 
          mygrid.enableMathSerialization(true);
as result all math based cells will be serialized as empty ones
Answer posted by Alexandre Lerat on Dec 12, 2008 02:18
Thanks for answers !!! My form works fine !!!