DHTMLX / scheduler

GPL version of JavaScript Event Scheduler
https://dhtmlx.com/docs/products/dhtmlxScheduler/
GNU General Public License v2.0
315 stars 111 forks source link

Scheduler - Drag drop item from list item to day,month,week and customized unit view #15

Closed gagankumar971 closed 8 years ago

gagankumar971 commented 8 years ago

dhtmlxscheduler.txt dhtmlxlist.txt

Hi, we have defined a layout of pattern: 2U , in the left panel we have attached listbox and rightpanel scheduler has been attached. Our requirement is to use drag and drop feature to drag an element from list and drop it to scheduler. I used the following method after include "dhtmlxscheduler_outerdrag.js" source : -

scheduler.attachEvent("onExternalDragIn", function(id, source, e) { var listItem = list.get(source.parentObject.id); scheduler.getEvent(id).text = listItem.Package + " " + listItem.Version; return true; });

the above functionality did not work, then I used "onBeforDragIn" event of list and override "scheduler._on_mouse_up" function of scheduler as follows : -

myList.attachEvent("onBeforeDragIn", function (context, ev){ // your code here console.log('hello 1'); dragIn = 1; listText = context.from.get(context.source[0]).Maintainer;

            var node = document.getElementById('1');
            //var node = document.getElementById('data_container');
            console.log('node is::::::::'+node);
            (new dhtmlDragAndDropObject()).addDraggableItem(node,{
                _createDragNode:function(node){
                    var dragSpan=node.cloneNode(true);
                    dragSpan.style.position="absolute";
                    dragSpan.style.zIndex=12;
                    return dragSpan;
                }, 
            });
            node.dragLanding=false;

            return true;
        });

(function(){ //inject custom mouseup handler var old = scheduler._on_mouse_up; scheduler._on_mouse_up = function(e){

            if (dragIn==1){ //debugger;
                var pos=this._mouse_coords(e);
                console.log('pos.x,pos.y'+pos.x + ' , ' + pos.y + '--------- ' + this._table_view);

                start=this._min_date.valueOf()+(pos.y*this.config.time_step+(this._table_view?0:pos.x)*24*60)*60000;

                start = this._correct_shift(start);
                mode = scheduler.getState().mode;
                console.log('mode inside onMouseUp is ::::: ' + mode);
                console.log(start);
                window.setTimeout(function(){   //timeout is necessary to prevent infinity loop

                scheduler.locale.labels.new_event = listText;

                if(mode=="unit"){

                    scheduler.addEventNow({
                    start_date: scheduler._get_date_from_pos(pos),
                    end_date:   scheduler._get_date_from_pos(pos),
                    text:   listText,
                    section_id: pos.section
                });

                }else
                    scheduler.addEventNow(start);

                scheduler.locale.labels.new_event = "New Event";

                },1)
                dragIn = 0;

            } else
                old.apply(this,arguments);
        }

    })();

the above code is working but It is required to change source code of dhtmlxscheduler.js for unit view and drag from list and drop to scheduler at particular position. It was also required to change in dhtmlxlist.js to make it workable in the current scenario.

To use the unit view we took the file from javaplanner(sample application) , it did not work, then we picked it up from "http://docs.dhtmlx.com/scheduler/codebase/ext/dhtmlxscheduler_units.js".

can we have source code for dhtmlxscheduler_units.js ?

For your kind concern, we have attached js files. please review it and let us know.

Thanks in advance....

gagankumar971 commented 8 years ago

Still waiting for reply. Can we have source code for dhtmlxscheduler_units.js file to use for "unit" view. Please reply.

AndroZoid commented 8 years ago

I'm interested too in unit view and dhtmlxscheduler_units.js. Is that in paid version only or could be added to repository?

AlexKlimenkov commented 8 years ago

Hi, 1) Issue with drag and drop seems to be resolved on forum http://forum.dhtmlx.com/viewtopic.php?f=6&t=50328

2) Units view is a part of Professional edition of dhtmlxScheduler, i.e. is not available under a free license. So, unfortunately, it won't appear here. If you have a paid version of a scheduler, you can find non-minified sources in /codebase/sources folder of a package.