PDA

View Full Version : [CLOSED] Different behavior of adding a record to a grid in 2.2



blueworld
Apr 10, 2013, 3:34 PM
Hello,

I have recently upgraded to ExtNet 2.2
I have a grid (Grid A) that allows to copy records into another grid (Grid B)

Since 2.2 the newly added record in Grid B always gets automatically selected. I do not want to get it selected at that moment because I have a select handler that is triggering now every time when I add a record to the grid. Is there any property to disable that behavior?

Regards

Daniil
Apr 10, 2013, 4:57 PM
Hi @blueworld,

I can't reproduce. A new added row is not selected in the test case below. Please provide your test case.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
Store store = this.GridPanel1.GetStore();
store.DataSource = new object[]
{
new object[] { "test1", "test2", "test3" },
new object[] { "test4", "test5", "test6" },
new object[] { "test7", "test8", "test9" }
};
store.DataBind();
}
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:Button runat="server" Text="Add" Handler="App.GridPanel1.getStore().add({});" />

<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test1" />
<ext:ModelField Name="test2" />
<ext:ModelField Name="test3" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test1" DataIndex="test1" />
<ext:Column runat="server" Text="Test2" DataIndex="test2" />
<ext:Column runat="server" Text="Test3" DataIndex="test3" />
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>

blueworld
Apr 11, 2013, 8:00 AM
Hi Daniil,
please see my simplified example, and yes here it does always select the new record which did not happen in 2.0, click the lorry icon to copy:




<script runat="server" >

Protected Sub Page_Load(sender As Object, e As EventArgs)
If Not ExtNet.IsAjaxRequest Then
Dim store As Store = Me.GridPanel1.GetStore()
store.DataSource = New Object() {New Object() {"test1", "test2", "test3"}, New Object() {"test4", "test5", "test6"}, New Object() {"test7", "test8", "test9"}}
store.DataBind()
End If
End Sub


</script>
<%@ Page Language="VB" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
<title>Ext.NET v2 Example</title>
<script>

function addData(record) {
var oldTest1 = record.get('test1')
var newRecord = record.copy();
// newRecord.data.test1 = <img src='ajaxpreloader.gif />
App.GridPanel2.store.insert(0, newRecord.data);
// calling a webservice and showing an ajax preloader in the column test1.

//webservice finished, set test1 to its old value:
newRecord = App.GridPanel2.getStore().getById(record.data.test 1);
newRecord.set("test1",oldTest1);
newRecord.commit();
}



</script>
</head>

<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Button ID="Button1" runat="server" Text="Add" Handler="App.GridPanel1.getStore().add({});" />

<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store ID="Store1" runat="server">
<Model>
<ext:Model ID="Model1" runat="server" >
<Fields>
<ext:ModelField Name="test1" />
<ext:ModelField Name="test2" />
<ext:ModelField Name="test3" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ID="Column1" runat="server" Text="Test1" DataIndex="test1" />
<ext:Column ID="Column2" runat="server" Text="Test2" DataIndex="test2" />
<ext:Column ID="Column3" runat="server" Text="Test3" DataIndex="test3" />
<ext:ImageCommandColumn ID="CommandColumn5" runat="server" Width="30">
<Commands>
<ext:ImageCommand Icon="LorryGo" CommandName="addToSecondGrid">
<ToolTip Text="Add to second Grid" />
</ext:ImageCommand>
</Commands>
<Listeners>
<Command Handler="addData(record);" />

</Listeners>
</ext:ImageCommandColumn>
</Columns>
</ColumnModel>
</ext:GridPanel>
<ext:GridPanel ID="GridPanel2" runat="server" >
<Store>
<ext:Store ID="Store2" runat="server" >
<Model>
<ext:Model ID="Model2" runat="server" IDProperty="test1">
<Fields>
<ext:ModelField Name="test1" />
<ext:ModelField Name="test2" />
<ext:ModelField Name="test3" />

</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel2" runat="server">
<Columns>
<ext:Column ID="Column4" runat="server" Text="Test1" DataIndex="test1" />
<ext:Column ID="Column5" runat="server" Text="Test2" DataIndex="test2" />
<ext:Column ID="Column6" runat="server" Text="Test3" DataIndex="test3" />

</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
</body>
</html>

Daniil
Apr 11, 2013, 10:12 AM
Thank you for a test case. Reproduced. We are investigating.

For now I can suggest to set up SelectionMemory="false" for the GridPanel.

Daniil
Apr 11, 2013, 10:23 AM
Regarding this:

newRecord.set("test1",oldTest1);

To set up a record's id, please use the setId method.
http://docs.sencha.com/ext-js/4-2/#!/api/Ext.data.Model-method-setId

It would be even better to avoid changing an id if possible.

Daniil
Apr 11, 2013, 10:42 AM
It has been fixed in SVN, please update and retest.

blueworld
Apr 11, 2013, 10:52 AM
Regarding this:

newRecord.set("test1",oldTest1);

To set up a record's id, please use the setId method.
http://docs.sencha.com/ext-js/4-2/#!/api/Ext.data.Model-method-setId

It would be even better to avoid changing an id if possible.

Hi Daniil,

in my real application I am changing my description property which is not the id, but thank you for the hint, I have just used randomly test1 in the example. What I do is showing an ajax preloader in the description column as long as the webservice does the request, and then displaying the original value again instead of the gif.

I will report back later if the SVN Update did help, thank you

blueworld
Apr 11, 2013, 2:07 PM
Hi Daniil,

the grid is now exactly working as before, thank you.

Daniil
Apr 11, 2013, 3:22 PM
Thank you for confirming!