Help - 2 tables for database and custom text box

Hello everyone!

This is my first post here, I am still in the learning phase, so have patience with me.

Here, i’m trying customize the text box for view day, I’m Loading into the blue box several records, but i have one especific column (from sql), called “event_motivo” that only points to another table.

My main SQL table is:

CREATE TABLE IF NOT EXISTS `records` ( `event_id` int(11) NOT NULL AUTO_INCREMENT, `event_start` datetime NOT NULL, `event_end` datetime NOT NULL, `event_text` text NOT NULL, `event_cliente` text NOT NULL, `event_cod_cliente` text NOT NULL, `event_fone` text NOT NULL, `event_motivo` text NOT NULL, PRIMARY KEY (`event_id`) );

Saying about the work already done:

scheduler.load("exec/data.php"); var dp = new dataProcessor("exec/data.php"); dp.init(scheduler);

data.php:

[code]$list = new OptionsConnector($res, $dbtype);
$list->render_table(“motivo”,“motivo_id”,“motivo_id(value),motivo_motivo(label)”);

	$scheduler = new schedulerConnector($res, $dbtype);
	$scheduler->set_options("event_motivo", $list);
	$scheduler->render_table("records","event_id","event_start,event_end,event_text,event_motivo,event_fone,event_cod_cliente,event_cliente");[/code]

Custom box code:

[code]scheduler.templates.event_text=function(start,end,event){

return “Client Name: " + event.event_client +
" | Evento: “+ event.event_motivo +”
”;
… }[/code]

Here the preview print:

Note that it brings the numerical value correctly. But as i said, i need mapping for the 2nd table:

View:

2nd SQL TABLE:

CREATE TABLE IF NOT EXISTS `motivo` (
  `motivo_id` int(11) NOT NULL AUTO_INCREMENT,
  `motivo_motivo` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`motivo_id`)
);

INSERT INTO `motivo` (`motivo_id`, `motivo_motivo`) VALUES
(1, 'Vestido de Venda');

And, the print of 2nd table:

So what i can do to show for view day, those values mapping from 2nd sql table?

Example of sucess:

I’ve tried (without success) running one ajax call (jquery) like:

function loadTextFrom2ndTable($value){ var request = $.ajax({ url: "exec/load.php", type: "GET", data: {'motivo' : $value }, //motivo dataType: "html" }); request.done(function( msg ) { return msg; }); }

And into html code, i’ve tried (without success) :

scheduler.templates.event_text=function(start,end,event){ ..... .... return ".... " + loadTextFrom2ndTable(event.event_motivo) ".... ";

But din’t work, i got some error message into blue box–> undefined

I’ve made some searchs, and found some like:

scheduler.parse(data, "json"); scheduler.updateView();

But i dont have any idea, anyone could help me?

Thanks

Two options

a) load the necessary info from the start. Instead of render_table you can use

$scheduler->render_sql(“select * from records INNER JOIN motivo on event_motivo = motivo_id”,“event_id”,“event_start,event_end,event_text,motivo_motivo,event_fone,event_cod_cliente,event_cliente”);

and use motivo_motivo in the client side template ( to have data saving you will need to define a separate render_table command just for saving
docs.dhtmlx.com/doku.php?id=dhtm … ral_tables

b) you can define a select box in lightbox and load the list of “motivo” in it, in such case you will be able to use getLabel methods inside of template.

docs.dhtmlx.com/scheduler/select.html
docs.dhtmlx.com/scheduler/api__s … label.html

thanks, problem solved!

Dear one question,

I´ve choosed your solution A. So, i´m using two “render_table” commands:

1st - loading data
2nd - other operations (update/insert/delete)

So, if i will update the value relating to another table what i can do to show to user the value updated? Refreshing the page is not a good idea haha…

Thanks

Anyone could help me?

The better solution in such case will be (b) from above post. In its case, you will need not any extra code to update the event after property change

In case of solution (a) it possible to set some extra data as part of response and use onAfterUpdate handler of dataprocessor, to read extra data from response and update it in the related event object.