 |
|
|
 |
|
 |
Amit,
Good way of promoting your code. This code was written when few peoples have knowledge about jquery.
|
|
|
|
 |
|
|
 |
|
 |
Good Morning Rupesh,
I read your article regarding the DragDrop GridView, it is a really great work and easy to use control that you have created.
I used is sucessfully within a stand alone page.
However when I added the control to a page with some Master pages and within the Content section, it is not calling the RaisePostBackEvent() now and as a result I am not able to catch the OnDragAndDrop() event.
Can you please guide/help in this regard.
Thank you very much in advance.
Regards,
Zubair Ahmed Khan
|
|
|
|
 |
|
 |
Hello!
i converted the sample code to vb.net and the draganddrop event doesn't fire. if i put the sample code in a c# file as advertised it works fine.
if i convert it and put in vb file, the event won't fire. this is driving me crazy...i'd really like to use this, but need it in vb...i think my vb syntax is ok.
what am i missing?
Thanks in advance!
Kelly
<@ Register Assembly="Utility" Namespace="Utility" TagPrefix="cc1" >
<cc1:dragdropgridview id="DragDropGridView1" runat="server" önDragAndDrop="DragDropGridView1_DragAndDrop">
CODE BEHIND:
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Partial Class About
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
GridDataBind()
End If
End Sub
Public Sub GridDataBind()
Dim objSet As New DataSet()
Try
objSet.ReadXml(Server.MapPath("XMLFile.xml"))
Catch
End Try
If objSet IsNot Nothing AndAlso objSet.Tables.Count > 0 Then
Dim objv As New DataView(objSet.Tables(0), "", "Order", DataViewRowState.CurrentRows)
DragDropGridView1.DataSource = objv
DragDropGridView1.DataBind()
End If
End Sub
Public Sub DragDropGridView1_DragAndDrop(ByVal sender As Object, ByVal e As Utility.DragAndDropEventArgs) Handles DragDropGridView1.DragAndDrop
Dim objSet As New DataSet()
Try
objSet.ReadXml(Server.MapPath("XMLFile.xml"))
Catch
End Try
If objSet IsNot Nothing AndAlso objSet.Tables.Count > 0 Then
Dim strTempOrder As String = objSet.Tables(0).Rows(e.StartIndex)("Order").ToString()
objSet.Tables(0).Rows(e.StartIndex)("Order") = objSet.Tables(0).Rows(e.EndIndex)("Order")
objSet.Tables(0).Rows(e.EndIndex)("Order") = strTempOrder
objSet.AcceptChanges()
Dim objv As New DataView(objSet.Tables(0), "", "Order", DataViewRowState.CurrentRows)
DragDropGridView1.DataSource = objv
DragDropGridView1.DataBind()
End If
End Sub
End Class
|
|
|
|
 |
|
 |
Hi, newly I'm writing...
now, i want tho ask to you if you do something to allow asign an SkinId at DragAndDropGridView, I want to use it but I need to set an SkinId for apply css styles..
I know I can set styles manually, but I want to know if is possible asign an SkinId because I'm tryed but I can't do it.
I hope you can help me... thnks..
|
|
|
|
 |
|
 |
(Im not speak english very well, therefore sorry for my issues :P )
I got the sample code for this very great gridview, but only fires the postback when i just do a "click" without drag, if I drag mouse postback do not raise.
I'm checking the code and I notice that never enter into this code when I drag the mouse, only when I do a "simple click":
string strStoptDragging =
@"function stopDragging" + this.ClientID + @"(position)
{
alert('este luego luego');// This is my test code
if(typeof(__isDrag" + this.ClientID + @") != 'undefined' && __isDrag" + this.ClientID + @" == true)
{
startPosition = __startPosition" + this.ClientID + @";
endPosition = position
cleardragging" + this.ClientID + @"();
var stp = startPosition;// This is my test code
var etp = endPosition;// This is my test code
alert('en el fin: ' + stp + ' : ' + etp);// This is my test code
.....
I hope you can help me...
PD: It is a great great gridview....
|
|
|
|
 |
|
 |
Hi, checking code for this control, I could get correct functionality !! ...
What I did ??? I comment :
"
document.onmousemove = function ()
{
if(__item" + this.ClientID + @" != null){
__item" + this.ClientID + @".style.left= window.event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft ;
__item" + this.ClientID + @".style.top = window.event.clientY + document.body.scrollTop + document.documentElement.scrollTop ;
}
}
"
from the startdraging function.... and with that gridview work great
the problem, now, is the div with the row values do not move :P , it shows but it still on bottom of gridview... maybe it not to be a problem, because I could do not use it
I hope, you can tell me something for gridview works prefectly at 100%.
Saludos...
|
|
|
|
 |
|
 |
Hi Rodrigo,
I try to understand your problem. I have checked that it is due to the IE version in IE 8 is not fired the mouseup event of the row. I try to find the workaround for it.
Can you please explain what you required from this code.
Regards,
Rupesh
modified on Friday, October 22, 2010 12:26 AM
|
|
|
|
 |
|
 |
I got the solution for it.
Just do some changes in utility source code so that it works perfectly.
1- Change this code in stopDragging function
if(startPosition != -1 && endPosition != -1)-->
if(startPosition != -1 && endPosition != -1 && startPosition !=endPosition )
so that it will not fire the postback if row move to the same row.
2- change in mouse move event so it is fire correct mouse up event
document.onmousemove = function ()
{
if(__item" + this.ClientID + @" != null){
__item" + this.ClientID + @".style.left= window.event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft ;
__item" + this.ClientID + @".style.top = window.event.clientY + document.body.scrollTop + document.documentElement.scrollTop ;
}
}
to
document.onmousemove = function ()
{
if(__item" + this.ClientID + @" != null){
__item" + this.ClientID + @".style.left= window.event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft + 5 + 'px' ;
__item" + this.ClientID + @".style.top = window.event.clientY + document.body.scrollTop + document.documentElement.scrollTop + 5 + 'px';
}
}
here i have added 5 px so that after drop it fire the mouse up event of the row.
I hope it resolve all your problem.
thanks,
rupesh
|
|
|
|
 |
|
 |
<!--
Hi,
I did modifications which you write in post.... Works Great !!! thnks..
Now, I can see anoother issue... if I move row 1 to row 3 it works fine... but if I want to move newly row 1 (actuall row 1) to row 4, change is between row 4 and row 5... and do not change row 1 for row 4...
I hope I have been write correctly and you can understand me..
thnks..
saludos...
----!>
Hi, I modify the code, and I could get my objective.
About the text above, only I have to order table before modify order items.... (this thing, because I added code because the sample code, use the same Data in each order of items).
Newly, I hope i wrote right and you can understand me....
PD: All works OK !!!!
PD: Todo funciona muy bien....
modified on Friday, October 22, 2010 3:54 PM
|
|
|
|
 |
|
 |
Hi,
I created the sample code just for showing the functionality . In the sample code i am using the dataset from XML file. The Issue you get due to the updated order is not saved back into XML file. And every time i bind the grid i fetch data from XML file and bind the grid after drag and drop operation.
There are 2 way to resolve this. One is use the dataset in ViewState and use the view state Dataset for binding the grid. So that it always show you updated Grid.
As per the utility there is no issue there. It was just of the sample code logic.
Regards,
Rupesh
|
|
|
|
 |
|
 |
Did anyone find out why it doesn´t work with masterpage ?
|
|
|
|
 |
|
 |
Hi,
It's working in Master Pages. Can you please explain what is the problem you facing. Becuase i have checked and find that it is not working in IE8 due to MouseDown event but it is working well in IE7.
Thanks
Rupesh
|
|
|
|
 |
|
 |
in paging its not working
|
|
|
|
 |
|
 |
Please see my comment for paged view.
If your requirement is different then let me know
|
|
|
|
 |
|
 |
I got the drag and drop working with an externat datatable.
<td colspan="2" align="right">
<cc1:DragDropGridView ID="DDOrders" runat="server" AutoGenerateColumns="false" OnDragAndDrop="ddOrders_DragAndDrop"
HeaderStyle-CssClass="GrdHeader" AlternatingRowStyle-CssClass="GrdAlternate"
OnRowDataBound="ddOrders_RowDataBound">
<Columns>
<asp:BoundField DataField="ordernumber" HeaderText="Order" HtmlEncode="false" HeaderStyle-HorizontalAlign="Left"
ItemStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="postcode" HeaderText="Postcode" HtmlEncode="false" HeaderStyle-HorizontalAlign="Left"
ItemStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="town" HeaderText="Woonplaats" HtmlEncode="false"
HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" />
<asp:TemplateField>
<itemtemplate>
<asp:CheckBox ID="chkSelect" runat="server" Value='<%# Eval("geselected") %>'/>
<asp:HiddenField Value='<%# Eval("ORDSHOLD_FLAG") %>' ID="ORDSHOLD_FLAG" runat="server" />
</itemtemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
Geen data.
</EmptyDataTemplate>
</cc1:DragDropGridView>
</td>
I found out that checking the checkbox (chkSelect) triggers also the dragDrop event.
It is also impossible to use the content of the field in the code behind of the drag drop event:
foreach (GridViewRow gvr in DDOrders.Rows)
{
if (gvr.RowType == DataControlRowType.DataRow)
{
Boolean LineChecked = ((CheckBox)gvr.FindControl("chkDDSelecteer")).Checked;
}
}
Someone any suggestions??
|
|
|
|
 |
|
 |
Any solution to this yet? I am having the same problem.
|
|
|
|
 |
|
|
 |
|
 |
Hi,
Event is fire becuase when you click on the check box it seems that you drag an item and drop it on that check box and due the mousedown script it fire the event.
Change the following line in Utility.dll / DragAndDropGrid
if(startPosition != -1 && endPosition != -1 )
with
if(startPosition != -1 && endPosition != -1 && startPosition != endPosition )
|
|
|
|
 |
|
 |
Pretty much as the subject says.
I have a dragdropgridview on the page with a sqldatasource and I keep getting null object references
when trying to drag and drop.
I know this will look very amateurish but:
Protected Sub DragDropGridView1_DragAndDrop(ByVal sender As Object, ByVal e As Utility.DragAndDropEventArgs) Handles DragDropGridView1.DragAndDrop
Dim objSet As DataSet = New DataSet
objSet = DragDropGridView1.DataSource()
Dim strTempOrder As String = objSet.Tables(0).Rows(e.StartIndex)("ID").ToString()
objSet.Tables(0).Rows(e.StartIndex)("ID") = objSet.Tables(0).Rows(e.EndIndex)("ID")
objSet.Tables(0).Rows(e.EndIndex)("ID") = strTempOrder
objSet.AcceptChanges()
Dim objv As New DataView(objSet.Tables(0), "", "ID", DataViewRowState.CurrentRows)
DragDropGridView1.DataSource = objv
DragDropGridView1.DataBind()
End Sub
Help?
|
|
|
|
 |
|
 |
Im trying your code and viewing it in Internet Explorer 8. I cannot get the event handler to fire off. No matter what Ive tried. I am using the code exactly like your sample as far as I can tell. Can anyone help me I spent a ton of time changing tables in my database and writing lots of supporting code that I was going to use along with this re-ordering. I really need this or something just like it. Thanks in advance for your time.
Update: I also have tried viewing my page in Firefox and IE 7 and I seem to have the same problem. Cannot get the code to break inside of the draganddrop method and a response.write to confirm if Im in the method or not never gets hit. Its just not firing that event handler???
modified on Monday, June 29, 2009 12:10 PM
|
|
|
|
 |
|
 |
Hi,
Your code was really helpful, But i have a new problem.
I have large amount of data to be displayed in the grid control and hence i have used paged view for the grid control.
How can i drag and drop the items from one page to another.
Any sort of code would be of gr8 help.
Thanks,
gayatri
|
|
|
|
 |
|
 |
Hi,
It is not possible in this control becuause in this control we drag one row and drop it another row. In case of pagging the another row will be invisible so you have to build different logic for your requirment.
create one box down the grid. Pull one item from grid view and drop it on the box. go to that page and pull the item from box and put it that row.
when you pull the item then maintain the row index or id and when you pull back then replace with that id.
|
|
|
|
 |
|
 |
DragDropGridView don't work with MasterPages.
The page's Postback fire but The method RaisePostBackEvent never is executed.
|
|
|
|
 |