Categories | Question details Back To List | ||
dhtmlxscheduler get sections from database I am using the Units extention without issue but am looking to improve it by getting the Sections from my database rather than hardcoding it in. I've looked through the documentation and can only see the sections being hard coded in. I've looked at the connector part but it appears as though you have to bind to a grid/combo or some other object whilst all I need to do is loop through the database results once. Is there something to do this task within dhtmlx? Thanks in advance, Preston Answer posted by Stanislav (support) on Oct 01, 2009 08:52 Current version doesn't support such functionality. You can use the next way to init the component dhtmlxAjax.get("config.php",function(loader){ eval(loader.xmlDoc.responseText); //default init code scheduler.locale.labels.unit_tab = "Unit" scheduler.locale.labels.section_custom="Section"; scheduler.config.details_on_create=true; scheduler.config.details_on_dblclick=true; scheduler.config.xml_date="%Y-%m-%d %H:%i"; scheduler.config.lightbox.sections=[ {name:"description", height:130, map_to:"text", type:"textarea" , focus:true}, {name:"custom", height:23, type:"select", options:sections, map_to:"section_id" }, {name:"time", height:72, type:"time", map_to:"auto"} ] scheduler.createUnitsView("unit","section_id",sections); scheduler.init('scheduler_here',new Date(2009,5,30),"unit"); scheduler.load("units.xml?uid="+scheduler.uid()); }); where config.php will output the necessary set of sections as plain text var sections=[ {key:1, label:"Section A"}, {key:2, label:"Section B"}, {key:3, label:"Section C"}, {key:4, label:"Section D"} ]; Above code will fetch section list, eval it, and run default init after that. We plan to add the ability to define sections through connector in nearest future ( server side already can generate value list , just need to be linked to the client side ) Answer posted by Preston on Oct 01, 2009 09:42 Thanks for the reply, I figured out a simple work around after I posted the question. I changed the file to .php and did a mysqli connection and sql statement to get the userid, firstname and lastname of the staff. I then looped through the results to produce the sections list with key and label, this was stored in a php variable. Then within the javascript I just added <?php echo $sections; ?> and i've got my sections defined. It's a bit more basic than method you described but it does the job. |