DataProcessor refresh issues

Hi Guys,

I created a application which uses the following components, layout, grid, datastore, dataprocessor, and in the backend im using django to do the bulk of the work… i have my components connected as follows:

The datastore is synced with the grid, and the dataprocessor is init’d to the datastore.,

the issue i am facing is that

  1. I create a new item in the datastore for the first time it works great, but when i create another item (without saveData for the first one) in the datastore it creates the item & the row in the grid but adds a dummy row which is un-selectable., it gets worse if i add a third item to the store it adds a item & two dummy items in the grid., and this keeps happening till i refresh the page, then the whole thing starts again.

  2. The edits made to the newly added row are not marked by the dataProcessor, even if it marks the row when i sendData it doesn’t generate a request

i’m having to reload all data on the page once something changes to cope with this… can some one tell me what i’m doing wrong

  # grids init
  root.inv_grid = root.layout1.cells("a").attachGrid()
  root.inv_grid.enableMultiselect(false)
  root.inv_grid.setDateFormat("%Y-%m-%d")
  root.inv_grid.init()
  root.inv_form = root.layout1.cells("b").attachForm()
  root.wa_li_grid = root.layout2.cells("a").attachGrid()
  root.wa_li_grid.enableMultiselect(true)
  root.wa_li_grid.setDateFormat("%Y-%m-%d")
  root.wa_li_grid.init()
  root.avial_shots_grid = root.layout2.cells("b").attachGrid()
  root.avial_shots_grid.enableMultiselect(true)
  root.avial_shots_grid.setDateFormat("%Y-%m-%d")
  root.avial_shots_grid.init()

  # datastores
  root.invoices_ds = new dhtmlXDataStore()
  root.lineitems_ds = new dhtmlXDataStore()
  root.avial_shots_ds = new dhtmlXDataStore()
  root.companies_ds = new dhtmlXDataStore()
  root.shows_ds = new dhtmlXDataStore()
  # load the grids & form
  root.inv_grid.loadXML("/static/Fintab/INV/xml/grids/config_inv_grid.xml")
  root.inv_form.loadStruct("/static/Fintab/INV/xml/forms/config_inv_form.xml")
  root.inv_form.bind(root.inv_grid)
  root.wa_li_grid.loadXML("/static/Fintab/INV/xml/grids/config_inv_li_grid.xml")
  root.avial_shots_grid.loadXML("/static/Fintab/INV/xml/grids/config_inv_li_grid.xml")
load_datastores = ->
  # invoices datastore events, actions
  root.invoices_ds.load(
    "/populate_ds/invoice/#{root.active_only}",
    "json",
  ->
    root.invoices_ds.filter(
      (obj, value) ->
        if obj.status isnt "Void"
          true
        else
          false
    )
    root.inv_grid.sync(root.invoices_ds)
    root.inv_form.bind(root.inv_grid)
    root.layout1.cells("a").progressOff()
    root.layout1.cells("b").progressOff()
  )

  #invoice items datastore init, events, actions
  root.lineitems_ds.load(
    "/populate_ds/invoice_lineitem/#{root.active_only}",
    "json",
  ->
    root.wa_li_grid.sync(root.lineitems_ds)
    root.layout2.cells("a").progressOff()
  )
# Dataprocessor for invoices
  root.invoice_dp = new dataProcessor("/crud/Invoice/")
  root.invoice_dp.setUpdateMode("off")
  root.invoice_dp.setTransactionMode('POST', true)
  root.invoice_dp.enableDataNames(true)
  root.invoice_dp.init(root.invoices_ds)
  # events
  root.invoice_dp.attachEvent('onBeforeDataSending', (id) ->
    root.main_layout.progressOn()
    true
  )
  root.invoice_dp.attachEvent('onFullSync', ->
    root.main_layout.progressOff()
    true
  )

Each code block is in a separate function block, and called in a logical order when the page loads using the dhtmlxEvent window, "load", function

  • please be sure that sync command is called only once ( you need not call sync after each store update )
  • I don’t see in code where new item is added to be store. Be sure that new item has unique id ( empty or non-unique id may cause the above problem
  • if issue still occurs - please try to update datastore.js with the attached one.
    datastore_latest.zip (24.7 KB)

thanks for the reply,

im calling the sync only once, and below is the code for adding a new row to the datastore

root.invoices_ds.add({
        id: root.inv_grid.uid()
        inv_id: root.inv_grid.uid(),
        status: "Pending",
        pmt_status: "Unpaid",
        company_id: company_combo.getSelectedText(),
        show_id: shows_combo.getSelectedText()
      })

what;s happening is it doesn’t send any data to the server after the first call to sendData…

so i’ve removed all the custom code and this is the error i get

Uncaught TypeError: Cannot set property 'idd' of undefined dhtmlx.js:763
changeRowId dhtmlx.js:763
(anonymous function) dhtmlx.js:2686
dhx.EventSystem.callEvent dhtmlx.js:2604
dhx.DataStore.changeId dhtmlx.js:2647
changeId dhtmlx.js:2670
dataProcessor.afterUpdateCallback dhtmlx.js:410
dataProcessor.afterUpdate dhtmlx.js:411
check

i think the error is occuring when im trying to insert a row & save, my server responds with the following xml

<?xml version="1.0"?>
<data>
    <action type="inserted" sid="TEST_004" tid="1399046828990" message=""/>
</data>

i’m using the dhtmlx_pro_full, so im not able to modify the datastore you have linked…, cant seem to compile it under mamp… but i doubt this is regarding the changeId when old != new

sorry for the trouble, i surely misread the documentation :frowning:
the issue was i was sending the wrong sid & tid’s
when inserting, sid is the old row id and tid is the new id…
i was doing it the otherway around… sorry again… :cry: :cry: