Jan 04, 2011, 2:28 PM
[CLOSED] GridPanel auto-loads when I manually add a row to it
Hi,
I have a grid panel that I add to using the results of a drag/drop action. However, as soon as the item is "dropped" into the grid panel, it triggers a reload of the contents of the grid panel. I've tried setting a bunch of properties on the store to stop this from happening, but every add to the gridpanel's store triggers a reload. Here is my code:
The HTML:
I have a grid panel that I add to using the results of a drag/drop action. However, as soon as the item is "dropped" into the grid panel, it triggers a reload of the contents of the grid panel. I've tried setting a bunch of properties on the store to stop this from happening, but every add to the gridpanel's store triggers a reload. Here is my code:
The HTML:
<ext:GridPanel Margins="10 10 10 10" ID="GridPanel2" runat="server" DDGroup="firstGridDDGroup"
EnableDragDrop="true" StripeRows="true" AutoExpandColumn="EmailAddress"
Width="300" MaxWidth="300" Title="Users in Role">
<Store>
<ext:Store ID="UsersSelectedStore" runat="server" RemoteSort="true" UseIdConfirmation="true" AutoDataBind="false" AutoLoad="false" AutoSave="false" RefreshAfterSaving="None">
<Proxy>
<ext:HttpProxy Url="/UserData/GetUsersByRole/"/>
</Proxy>
<UpdateProxy>
<ext:HttpWriteProxy Url="/UserData/SaveSelectedUsers/" />
</UpdateProxy>
<Reader>
<ext:JsonReader IDProperty="UserId" Root="data" TotalProperty="total">
<Fields>
<ext:RecordField Name="UserId" SortDir="ASC" />
<ext:RecordField Name="Forename" />
<ext:RecordField Name="Surname" />
<ext:RecordField Name="CreationDate" Type="Date" />
<ext:RecordField Name="EmailAddress" />
</Fields>
</ext:JsonReader>
</Reader>
<BaseParams>
<ext:Parameter Name="roleid" Value="#{txtHiddenRoleId}.getValue()" Mode="Raw" />
</BaseParams>
<SortInfo Field="UserId" Direction="ASC" />
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ColumnID="Surname" Header="Surname" Width="80" DataIndex="Surname" />
<ext:Column Header="Forename" Width="80" DataIndex="Forename" />
<ext:Column Header="EmailAddress" Width="80" DataIndex="EmailAddress" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel2" runat="server" />
</SelectionModel>
</ext:GridPanel>
<ext:DropTarget ID="DropTarget2" runat="server" Target="={GridPanel2.view.scroller.dom}"
Group="secondGridDDGroup" AutoDataBind="false">
<NotifyDrop Fn="notifyDrop2" />
</ext:DropTarget>
The Javascript that adds a new row to the panel var notifyDrop2 = function (ddSource, e, data) {
// Loop through the selections
//alert(Ext.get('UserIds'));
Ext.each(ddSource.dragData.selections, function (record) {
addRow(UsersSelectedStore, record, ddSource);
});
return true;
};
var addRow = function (store, record, ddSource) {
// Search for duplicates
var foundItem = store.findExact('EmailAddress', record.data.Name);
// if not found
if (foundItem == -1) {
//Remove Record from the source
ddSource.grid.store.remove(record);
store.add(record);
// Call a sort dynamically
store.sort('Surname', 'ASC');
}
};
Last edited by mattwoberts; Jan 04, 2011 at 2:56 PM.