search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

How to populate second RowHeader from database

Asked by Rafael
4 years ago.

Hi,

I'm testing DayPilot Pro for JavaScript and it's great !

In my Scheduler (Row header), I would like to have :

  • column 1 : name of project ("name" field in my MySQL datasource) --> It's OK
  • column 2 : days of workloads planned for the project ("daysnb" field in my MySQL datasource) --> :(

For the second column, I haven't figured out a way of doing the map between my data and the innerHtml, in order to populate this column.

My code in "backend_project.php" :

    ...
    $aMissionList = CMDBSource::QueryToArray($sMissionListSQL);
    class Mission {}
    $result = array();
    foreach($aMissionList as $mission) {
      $r = new Mission();
      $r->id = $mission['id'];
      $r->name = $mission['last'].' - '.$mission['first'];
      $r->daysnb = $mission['days_nb'];
      $result[] = $r;
     }
    header('Content-Type: application/json');
    echo json_encode($result);
My code in "index.php" :
    var projecturl = "backend_project.php?user=" + item.id;
    	  dp.rows.load(projecturl, function (args) {
            args.data.splice(0, 0, {id: "L" + item.id, name: item.name, daysnb: item.daysnb, type: "user"});
          });

I don't know how to use the new parameter "item.daysnb" to display the value in the right column.

Can you help me ?

Regards,

Rafael.

Comment posted by Rafael
4 years ago.

In addition, a screenshot : https://i.goopics.net/o3kO7.jpg

Answer posted by Dan Letecky [DayPilot]
4 years ago.

You can set the column data source using "display" property of the rowHeaderColumns[] array items:

This requires DayPilot Pro for JavaScript version 2019.4.4073 or later (with the tabular mode support):

Example:

dp.resources = [
  { id: "101", name: "Mission 101", daysnb: 2 },
  { id: "102", name: "Mission 102", daysnb: 3 },
];

dp.rowHeaderColumns = [
  { text: 'Name', display: "name" },
  { text: 'Days', display: "daysnb" }
];

See also:
https://doc.daypilot.org/scheduler/row-header-columns/

Comment posted by Rafael
4 years ago.

Hi Dan !

Thank you for your answer.
I just have a look on Pro versions and I have a question. I would like to use 2 schedulers in my application. Is the "Web Start" can only be use for one scheduler instance ?

Rafael.

Comment posted by Dan Letecky [DayPilot]
4 years ago.

Hi Rafael,

The "Web Start" edition includes one application but within that application you can use multiple Scheduler instances.

Comment posted by Rafael
4 years ago.

Ok !
I imagine I have to point on a single .js file in all my instances ?

Comment posted by Dan Letecky [DayPilot]
4 years ago.

You can use it at multiple places within one internal project/application, e.g. to manage people at one page and to manage related rooms at another page. You should use the same .js file.

Just note that you can't make it available to your other (internal) projects by sharing the js file. In that case, you'd need the multi-app license (Web Office).

Comment posted by Rafael
4 years ago.

Ok, it's clear !
I'll order on Monday.

Thank you for your help !

Rafael.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.