PDA

View Full Version : [CLOSED] Enable/disable drag/drop of grid rows from one to another



Sowjanya
Aug 16, 2013, 5:16 AM
Hi,

I have a grid panel for which I have a dradrop control inside grid view. I have enabledrop as "false" initially....When i try to set it to true in code behind, i
am still unable to drop on this grid.

Pls help me resolve this.

Thanks,
Veda

Daniil
Aug 16, 2013, 5:52 AM
Hi Veda,

Yes, changing EnableDrop when a GridPanel is already rendered doesn't work.

I can suggest the following solution.

To disable dropping initially:

<ext:GridView runat="server">
<Plugins>
<ext:GridDragDrop PluginId="dragdrop" runat="server" DragText="Drag and drop to reorganize" />
</Plugins>
<Listeners>
<AfterRender Handler="this.getPlugin('dragdrop').dropZone.lock();" Delay="1" />
</Listeners>
</ext:GridView>

To enable on the fly:

grid.getView().getPlugin('dragdrop').dropZone.unlo ck();

aditya
Mar 25, 2014, 7:52 AM
Hi Veda,

Yes, changing EnableDrop when a GridPanel is already rendered doesn't work.

I can suggest the following solution.

To disable dropping initially:

<ext:GridView runat="server">
<Plugins>
<ext:GridDragDrop PluginId="dragdrop" runat="server" DragText="Drag and drop to reorganize" />
</Plugins>
<Listeners>
<AfterRender Handler="this.getPlugin('dragdrop').dropZone.lock();" Delay="1" />
</Listeners>
</ext:GridView>

To enable on the fly:

grid.getView().getPlugin('dragdrop').dropZone.unlo ck();

I Followed above suggestion but I get following error.
Error: Unable to get property 'dropZone' of undefined or null reference



<ext:Store ID="StoreDBScript" runat="server" PageSize="50">
<Model>
<ext:Model ID="StoreModelDBScript" runat="server" IDProperty="DBScriptId" ClientIdProperty="DBScriptId">
<Fields>
<ext:ModelField Name="DBScriptId" />
<ext:ModelField Name="DBBuildId" />
<ext:ModelField Name="Name" />
<ext:ModelField Name="DBScriptType" Type="Int" UseNull="true"/>
<ext:ModelField Name="DBChangeType" Type="Int" UseNull="true"/>
<ext:ModelField Name="Description" />
<ext:ModelField Name="Reference" />
<ext:ModelField Name="Sequence" Type="Int"/>
<ext:ModelField Name="Script" />
<ext:ModelField Name="ChangedBy" />
<ext:ModelField Name="ChangedOn"/>
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:Viewport ID="ViewportDBScript" runat="server" Layout="VBoxLayout">
<LayoutConfig>
<ext:VBoxLayoutConfig Align="Stretch" />
</LayoutConfig>
<Items>
<ext:GridPanel
ID="DBScriptGrid"
runat="server"
Header="False"
ColumnLines="True"
Region="Center"
EmptyText="No Records Found"
SortableColumns="true"
StoreID="StoreDBScript"
Flex="3">
<ColumnModel ID="DBScriptColumnModel" runat="server" Enabled="false">
<Columns>
<ext:Column ID="ColumnScriptName" runat="server" Flex="1" Text="Name" DataIndex="Name">
<Editor>
<ext:TextField ID="TextScriptName" runat="server">
</ext:TextField>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModelDBScript" runat="server">
</ext:RowSelectionModel>
</SelectionModel>
<Plugins>
<ext:CellEditing ID="CellEditing1" runat="server" ClicksToEdit="1">
</ext:CellEditing>
</Plugins>
<View>
<ext:GridView ID="GridViewDBScript" runat="server">
<Plugins>
<ext:GridDragDrop PluginId="DragDropDBScript" runat="server" DragText="Drag and drop"/>
</Plugins>
</ext:GridView>
</View>
<TopBar>
<ext:Toolbar ID="ToolbarDBScript" runat="server" Height="30" Flex="1">
<Items>
<ext:Label runat="server" ID="titleDBScripts" Text="DB Scripts" Icon="ApplicationViewList" Cls="lblcss" Flex="1"/>
<ext:Label runat="server" ID="Label1" Cls="lblcss" flex="1"/>
<ext:Button ID="btnEdit" runat="server" Text="Edit" Disabled="true" ToolTip="Edit Data">
<Listeners>
<Enable Handler="App.DBScriptGrid.getView().getPlugin('DragDropDBSc ript').dropZone.lock();" />
<Disable Handler="App.DBScriptGrid.getView().getPlugin('DragDropDBSc ript').dropZone.unlock();" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:GridPanel>
</Items>
</ext:Viewport>

Daniil
Mar 25, 2014, 3:53 PM
I Followed above suggestion but I get following error.
Error: Unable to get property 'dropZone' of undefined or null reference



<ext:Store ID="StoreDBScript" runat="server" PageSize="50">
<Model>
<ext:Model ID="StoreModelDBScript" runat="server" IDProperty="DBScriptId" ClientIdProperty="DBScriptId">
<Fields>
<ext:ModelField Name="DBScriptId" />
<ext:ModelField Name="DBBuildId" />
<ext:ModelField Name="Name" />
<ext:ModelField Name="DBScriptType" Type="Int" UseNull="true"/>
<ext:ModelField Name="DBChangeType" Type="Int" UseNull="true"/>
<ext:ModelField Name="Description" />
<ext:ModelField Name="Reference" />
<ext:ModelField Name="Sequence" Type="Int"/>
<ext:ModelField Name="Script" />
<ext:ModelField Name="ChangedBy" />
<ext:ModelField Name="ChangedOn"/>
</Fields>
</ext:Model>
</Model>
</ext:Store>

<ext:Viewport ID="ViewportDBScript" runat="server" Layout="VBoxLayout">
<LayoutConfig>
<ext:VBoxLayoutConfig Align="Stretch" />
</LayoutConfig>
<Items>
<ext:GridPanel
ID="DBScriptGrid"
runat="server"
Header="False"
ColumnLines="True"
Region="Center"
EmptyText="No Records Found"
SortableColumns="true"
StoreID="StoreDBScript"
Flex="3">
<ColumnModel ID="DBScriptColumnModel" runat="server" Enabled="false">
<Columns>
<ext:Column ID="ColumnScriptName" runat="server" Flex="1" Text="Name" DataIndex="Name">
<Editor>
<ext:TextField ID="TextScriptName" runat="server">
</ext:TextField>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModelDBScript" runat="server">
</ext:RowSelectionModel>
</SelectionModel>
<Plugins>
<ext:CellEditing ID="CellEditing1" runat="server" ClicksToEdit="1">
</ext:CellEditing>
</Plugins>
<View>
<ext:GridView ID="GridViewDBScript" runat="server">
<Plugins>
<ext:GridDragDrop PluginId="DragDropDBScript" runat="server" DragText="Drag and drop"/>
</Plugins>
</ext:GridView>
</View>
<TopBar>
<ext:Toolbar ID="ToolbarDBScript" runat="server" Height="30" Flex="1">
<Items>
<ext:Label runat="server" ID="titleDBScripts" Text="DB Scripts" Icon="ApplicationViewList" Cls="lblcss" Flex="1"/>
<ext:Label runat="server" ID="Label1" Cls="lblcss" flex="1"/>
<ext:Button ID="btnEdit" runat="server" Text="Edit" Disabled="true" ToolTip="Edit Data">
<Listeners>
<Enable Handler="App.DBScriptGrid.getView().getPlugin('DragDropDBSc ript').dropZone.lock();" />
<Disable Handler="App.DBScriptGrid.getView().getPlugin('DragDropDBSc ript').dropZone.unlock();" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:GridPanel>
</Items>
</ext:Viewport>


This question has been asked here:
http://forums.ext.net/showthread.php?30201