Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by tom on Jul 02, 2009 03:09
open dhtmlx forum
Dhtmlx Scheduler

Hi i'm french,

I have two: tables agenda_calendrier and agenda_evenement. An event belongs to a calendar.

$scheduler->render_table("agenda_evenement","id","date_deb,date_fin,nom","calendrier_id");

When I try to create an event, I get this error :s :

this.obj.rowsAr is undefined
dhtmlxsc..._debug.js (ligne 1523) if (!this.obj.rowsAr[rowId])\r\n

I use postgresSql. Any idea?

Thanks
Answer posted by Support on Jul 02, 2009 04:46
Please try to update js file to attached one. 
( most probably the issue was caused by the problem in debug version of code )


Attachments (1)
Answer posted by tom on Jul 02, 2009 05:05
Thank you for this answer, but I have this in log now:

row 1246535792165 marked [inserted,valid]
 Initiating data sending for 1246535792165
 Initiating data sending for all rows
 Sending all data at once
 Server url: calendrier/Event?editing=true parameters
1246535792165_start_date=2009-7-1 08:45
1246535792165_end_date=2009-7-1 11:40
1246535792165_text=New%20event
1246535792165_id=1246535792165
1246535792165_extra_data=%5Bobject%20Object%5D
1246535792165_!nativeeditor_status=inserted
ids=1246535792165
 Server response received details
<?xml version='1.0' ?><data><action type='error' sid='1246535792165' tid='1246535792165' ></action></data>
 Action: error SID:1246535792165 TID:1246535792165
 row 1246535792165 unmarked [updated,error]

But I always block on this error which remains very vague. I think that it comes of calendrier_id which is a foreign key.

Thanks

Answer posted by Support on Jul 02, 2009 05:15
When you creating new event, it will generated insert query only for "date_deb,date_fin,nom" and if you DB has constraints - it may block insert operation without foreign key specified.

You can
a) enabled server side logging and check exact DB response 
   $scheduler = new schedulerConnector($res);
   $scheduler->enable_log("log.txt",true);

b) you can use server side events to add extra fields in query
   function some_code($action){
            $action->add_field("calendrier_id",SOME_VALUE);
   }
   $scheduler->event->attach("beforeInsert","some_code");

where SOME_VALUE - value which need to be used as foreign key
Answer posted by tom on Jul 02, 2009 05:31
Here is my code with the modifications, I always have the same error


   public function executeEvent(sfWebRequest $request)

    {
              include ('connector/scheduler_connector.php');

        $res=pg_connect("host=localhost port=5432 dbname=w3box user=w3soft password=password");
        
        $scheduler = new schedulerConnector($res);
        $scheduler->enable_log("log.txt",true);
      
        $scheduler->render_table("agenda_evenement","id","date_deb,date_fin,nom,description,adresse");
        $scheduler->event->attach("beforeInsert","some_code");
        return sfView::NONE;
    }    
   public function some_code($action)
      {
        $action->add_field("calendrier_id",2);
    }

I am spirit of integrated the schedule has a framework: Symfony ^^ but it's not very easy.

Thank you for your answers.
tom
Answer posted by Support on Jul 02, 2009 06:25
a)  You need to change the order of commands

$scheduler->event->attach("beforeInsert","some_code");
$scheduler->render_table("agenda_evenement","id","date_deb,date_fin,nom,description,adresse");

render_* method must be the last command to the connector ( all commands after that point will be ignored ) 

b) please be sure that "some_code" function is visible from executeEvent context

c) used syntax is common for simple functions, if you are working with objects , you can use
              $scheduler->event->attach("beforeInsert",array($class,"some_code"));
   
 
Answer posted by tom on Jul 02, 2009 06:51
Thank you very much I have the display and the update which works but always not the insert    :s

I don't know how to test the class som_code because I call it ajax there.

Thank you for your answers.
tom

Answer posted by Support on Jul 02, 2009 07:35
What is the content of "log.txt" in case of problematic operation?

>>I don't know how to test the class som_code because I call it ajax there.
Assuming, that you are using connectors 0.9
Comment next lines in base_connector.php

lines 13-14
   ini_set("output_buffering","On");
   ob_start();

line 255
  ob_clean();

without them - any error info , generated to php , will be included in server side response. ( which can be checked by firebug-like plugin, or through "response" link in debug version of script ) 

Answer posted by tom on Jul 03, 2009 01:36
Hello,
Everything's working very well ^^ thank you very much.
The insert is working, but i can't update if i don't reload the page.

Thanks
tom
Answer posted by Stanislav on Jul 03, 2009 14:41
>>The insert is working, but i can't update if i don't reload the page.
Is problem occurs only for newly added records? In  such case, most possible, that server side doesn't return correct new ID after insert operation. ( you can use debug js file and check the ction@tid in insert response - it must be a new ID ) 
Such problem must not occur for default insert operation, but if you are using custom SQL or PHP logic for new record adding - you need to provide info about new record as well


  function some_other_code($action){
            $action->success($id);
  }
  $scheduler->event->attach("afterInsert",array($class,"some_other_code"));

Where $id - id of newly added row.
Answer posted by tom on Jul 07, 2009 03:49
thanks.

i'd like to make a multi-table request now: here is my database:


    agenda_calendrier:
        id:                   ~
        user_id:              { type: integer, required: true, foreignTable: sf_guard_user, foreignReference: id }
        nom:                  { type: varchar(255), required: true }
        description:          { type: longvarchar }
        type:                 { type: boolean, required: true, default: 0 }
        libelle:              { type: varchar(255) }
        default_cal:              { type: boolean, required: true, default: 0 }
        created_at:           ~
        updated_at:           ~
 
    agenda_evenement:
        id:                   ~
        calendrier_id:        { type: integer, required: true  }
        id_parent:            { type: integer }
        nom:                  { type: varchar(255) }
        adresse:              { type: varchar(255) }
        description:          { type: varchar(255) }
        date_deb:             { type: timestamp, required: true }
        date_fin:             { type: timestamp, required: true }

Is this possible to display all the events of a user, or the events of some calendars, or just one calendar?

Freedom's coming after that =)

Answer posted by Support on Jul 07, 2009 06:09
Instead of render_table method of connector, you can use render_sql

$sched->render_sql("SELECT *, b.id as event_id FROM agenda_calendrier a INNER JOIN agenda_evenement b ON a.id  = b.calendrier_id WHERE some rules here ", "event_id","date_deb,date_fin,description")

In such case the code will select dataset based on provided SQL query and output it to client side in correct format. 
In case of render_sql usage, component will not be able to create insert|delete|update operations automatically, so you will need to redefine them through sql code or through events.