Issue with DragDropBlock?

Posted by: alkesh on 8 September 2017, 12:45 pm EST

  • Posted 8 September 2017, 12:45 pm EST

    Hi,


    Overview:


    I am developing a schedule grid using the farpoint spread sheet in X(dates) by Y(time of the day in 5 minutes solts) format. User can schedule items by dragging and dropping it to a different location. I have scheduled the items based on the location and on the grid and spanned the item depending on the item length. An item is identified by displaying the spanned cell in different color.


    When a user drags and drops an item and a item already exits then that item should be replace by the item just dropped, whereever it may be.


    Scenario and Issue:


    There is an item already scheduled at cell location (5,5) and its length is say 6. So it will span in X direction till (5,10). Now if  I drag another item from the grid which has same length 6 and If it exactly operlaps, the mouse pointer is appended by a rectangle, indicating that you can drop the item at that location. And everything works well. 


    Now when I move by cursor one pixel to right or left the rectangle turns into a black circle with a line across in it indicating that this item cannot be dropped at that location. This also happens when the length of items is different. Eg. When the length of the item on the grid is 10 and the length of the item being dropped is 5. The underlying item does not accepts the item being drop on itself. Can you please let me the solution for this?


    Please note, I have a requirement that the user can schedule items anywhere in the grid and the I have written a custom logic to schedule items and span them.


    Please let me know in case you need any further details.


    Thanks & Regards,


    Alkesh

  • Replied 8 September 2017, 12:45 pm EST

    Hello,


    This is the intended behavior. The Spread is not going to allow a smaller span to overwrite a larger span. This will mess up how the span is displayed. Spread would not how you want the two spans to be in this area after the drag, so we do not allow it. I would suggest not using spans, but rather merge data together in the cells to make it look like the cells are spanned.

  • Replied 8 September 2017, 12:45 pm EST


    Hi Scotts,


    I am relatively new to farpoint. Can you please let me know how do we merge data in the cells so that it appears as it is spanned (without actually spanning the cells)?


    Thanks & Regards,


    Alkesh Patel

  • Replied 8 September 2017, 12:45 pm EST

    Alkesh,


    We would need to see the code you are using to try to implement this. Could you post a small zipped project reproducing this issue for us to debug?

  • Replied 8 September 2017, 12:45 pm EST

    Scotts,


    I would have to spend substantial time to make a separate project which you have asked. I will do that later, if the following does'nt help.


    Please refer screen shot


    Form laod....


    Setting up rows headers and column headers and loading items (we call it Plays).


    It also calls PresentGrid()


    public void PresentGrid()


    {


    foreach(ScheduleSlot t_ScheduleSlot in this.ScheduleSlotList)


    {


    Schedule(t_ScheduleSlot);


    }


    }


    ScheduleSlotList is the collection of the ScheduleSlot on the grid. Each ScheduleSlot object has information such that PresentGrid() can decide where to place it.


    protected void Schedule(ScheduleSlot argScheduleSlot)


    {


    //ColumnSpan depends upon the length of the play


    this.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,argScheduleSlot.ColStart].ColumnSpan =


    25


    //Assign color to the slot


    this.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,argScheduleSlot.ColStart].BackColor = Color.Yellow


    //Display text in the slot


    this.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,argScheduleSlot.ColStart].Value = argScheduleSlot.DisplayText;


    }


    private void DragDropBlock(object sender, DragDropBlockEventArgs e)


    {


    if(this.m_ScheduleSlot!= null)


    {


    if(this.HandleConflict(m_ScheduleSlot,e.DestinationRowBegin,e.DestinationColumnBegin,this.m_ScheduleSlot.SchedulePlay.PlayLength).Equals(DialogResult.Yes))


    {


    this.ResetSlotAppearance(this.m_ScheduleSlot);


    this.m_ScheduleSlot.SchedulePlay.StartTime = this.m_ScheduleSlot.GetColDateTime(e.DestinationColumnBegin);


    this.m_ScheduleSlot.SchedulePlay.PlayDate = this.m_ScheduleSlot.GetRowDateTime(e.DestinationRowBegin);


    this.PresentGrid();


    }


    e.Cancel = true;


    }


    public void ResetSlotAppearance(ScheduleSlot argScheduleSlot)


    {


    this.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,argScheduleSlot.ColStart].ColumnSpan = 1;


    this.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,argScheduleSlot.ColStart].BackColor = Color.White;


    this.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,argScheduleSlot.ColStart].Value = String.Empty;


    }


    Please note that DragDropBlock itself is not getting fired when I drag a slot over another slot.


    I hope my previous post and this one should help. Please let me know in case of any questions.


     

  • Replied 8 September 2017, 12:45 pm EST

    Please find the screenshot. Missed it earlier


    2007/08/DragDropBlock.zip
  • Replied 8 September 2017, 12:45 pm EST

    Alkesh,


    If you have cells next to each other with the same data and set the SetColumnMerge and/or SetRowMerge methods, then Spread will automatically group those like data togeter and display it once (like a span) without an actual span.

  • Replied 8 September 2017, 12:45 pm EST

    Thank you for your inputs.


    I managed to pull off almost similar functionality with SetRowMerge () method you suggested.


    Here is the snippet of code I modified


    int t_ColCount = this.NbrOfColsInSlot(argScheduleSlot);


    String t_DisplayString = argScheduleSlot.DisplayText;


    for(int i = argScheduleSlot.ColStart; i <= (argScheduleSlot.ColStart + t_ColCount -1); i++ )


    {


    t_DisplayString = String.Concat(t_DisplayString,"\t",t_DisplayString);


    this.fpScheduleSpreadSheet.Cells[argScheduleSlot.RowStart,i].BackColor = argScheduleSlot.SchedulePlay.ScheduleItem.Color;


    }


    t_DisplayString.TrimEnd('\t');


    this.fpScheduleSpreadSheet.SetClipValue(argScheduleSlot.RowStart,argScheduleSlot.ColStart, 1, t_ColCount, t_DisplayString);


     


    I am facing couple of issued


    --> I want the rows of the grid to be locked. When I do that SetClip() method doesnot seem to be working.


    Thoughts?


    --> Is there a straight way to select the entire range of merged cells?


    I mean if I select 6th cell of an item(play) the entire play(item) would get selected.


    Thanks once again for your help


    Alkesh Patel

  • Replied 8 September 2017, 12:45 pm EST

    Alkesh,


    1) You can set the Protect property of the Spread to False before calling SetClip to get the data into the Spread. Then you can set the Protect property back to True, to lock all the cells marked with Locked=True.


    2) There is not a way to select all cells in a range. The difference between this and spans is this has all cells working independently of each other.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels