PDA

View Full Version : [CLOSED] mysterious server error about deserializing object in v2.1



CarpFisher
Jul 20, 2012, 1:41 PM
I will the mysterious error that popup when switching to v2.1. It is about a gridpanel selection in the postback but I'm not sure which event that generate that postback. With the same code this does not appear in v2.0




Server Error in '/' Application.
--------------------------------------------------------------------------------

Unexpected end when deserializing object. Path '[0]', line 1, position 2.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Newtonsoft.Json.JsonSerializationException: Unexpected end when deserializing object. Path '[0]', line 1, position 2.

Source Error:


Line 320: StringReader sr = new StringReader(val);
Line 321:
Line 322: this.selectedRows = (SelectedRowCollection)serializer.Deserialize(sr, typeof(SelectedRowCollection));
Line 323: }
Line 324:


Source File: C:\ExtNetSource2.1\Ext.Net\Ext\Selection\RowSelect ionModel.cs Line: 322

Stack Trace:


[JsonSerializationException: Unexpected end when deserializing object. Path '[0]', line 1, position 2.]
Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.CheckedRead(JsonReader reader) +56
Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) +33
Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) +98
Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.PopulateList(IWrappedCollection wrappedList, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id) +723
Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id) +193
Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) +125
Newtonsoft.Json.Serialization.JsonSerializerIntern alReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) +462
Newtonsoft.Json.JsonSerializer.DeserializeInternal (JsonReader reader, Type objectType) +405
Newtonsoft.Json.JsonSerializer.Deserialize(TextRea der reader, Type objectType) +44
Ext.Net.RowSelectionModel.LoadPostData(String postDataKey, NameValueCollection postCollection) in C:\ExtNetSource2.1\Ext.Net\Ext\Selection\RowSelect ionModel.cs:322
Ext.Net.RowSelectionModel.System.Web.UI.IPostBackD ataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) in C:\ExtNetSource2.1\Ext.Net\Ext\Selection\RowSelect ionModel.cs:266
System.Web.UI.Page.ProcessPostData(NameValueCollec tion postData, Boolean fBeforeLoad) +9046758
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +878




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

Daniil
Jul 20, 2012, 2:25 PM
Hi,

I am unable to reproduce.

Please provide the GridPanel configuration.

CarpFisher
Jul 20, 2012, 3:58 PM
I tried my best to create a simple version by trace all the events and simulating that, but no success, the error didn't popup... and it is not possible to send the source code....

However i've figured out the pattern of that is after I loaded the grid with data and some selections, I refresh the page with the browser's refresh button, then load the grid data and selection again and then the error popup....I've been scratching my head and have no idea....

Daniil
Jul 20, 2012, 4:02 PM
I just need the GridPanel and SelectionModel configuration for the beginning.

CarpFisher
Jul 20, 2012, 4:12 PM
I've managed to get more info about this issue:

The postCollection variable contains this:

postCollection = {submitDirectEventConfig=%7b%22config%22%3a%7b%22v iewStateMode%22%3a%22enabled%22%2c%22extraParams%2 2%3a%7b%22score%22%3a50%7d%7d%7d&ucPCPanel_cpcPanel_cboClientName=CHRISTODOULOU+MR. +G&_ucPCPanel_cpcPanel_cboClientName_state=%5b%7b%22v alue%22%3a648839%2c%22text%22%3a%22CHRISTODOULOU+M R.+G%22%2c%22index%22%3a0%7d%5d&ucPCPanel_cpcPanel_txtBanker=Adams+RY+Mr&ucPCPanel_cpcPanel_txtAdviser=CH+Ip&Email=greg%40mrfuntubbles.co.za&ucPCPanel_cpcPanel_txtID=6707315071088&ucPCPanel_cpcPanel_txtCellPhone=837002888&ucPCPanel_cpcPanel_txtBusPhone=7272500&ucPCPanel_cpcPanel_txtResPhone=7272590&ucPCPanel_cpcPanel_hdnClientID=648839&ucPCPanel_invPanel_ExtInvSelectionModel=%5b%7b&ucPCPanel_invPanel_ProposedInvSelectionModel=%5b%7 b&ucPCPanel_TabPanel2=ucPCPanel_pnlInvestment%3a2&__EVENTTARGET=ResourceManager1&__EVENTARGUMENT=ucPCPanel_invPanel_piiControl%7cpu blic%7cUpdateDefaultScore&__VIEWSTATE=...}




and

this.ConfigID = "ucPCPanel_invPanel_ExtInvSelectionModel"

which is the ID of the SelctionModel, and which has the value:

val = "[{"

That is why when it tried to Deserialize it complains at line 1 position 2 because it is not a proper object.

The question is how the SelectionModel gets that value of just "[{" ???

are some characters not escaped properly ?

CarpFisher
Jul 20, 2012, 4:14 PM
Thanks. Here is my grid panel code:


<ext:GridPanel ID="gdpExtInv" runat="server" Selectable="true" >

<View>
<ext:GridView ID="GridView1" runat="server" LoadMask="true" LoadingText="Loading..." />
</View>
<Store>
<ext:Store ID="strExtInv" runat="server" >
<%-- <Listeners>
<Refresh Handler="Ext.net.Bus.publish('App.Change.Investments.Existi ng');"></Refresh>
</Listeners> --%>
<Model>
<ext:Model ID="Model1" runat="server" IDProperty="objectID">
<Fields>

<ext:ModelField Name="objectID" />
<ext:ModelField Name="productName" />
<ext:ModelField Name="contractID" />
<ext:ModelField Name="investAmount" Type="Float" />
<ext:ModelField Name="productType" />
<ext:ModelField Name="source" />
<ext:ModelField Name="isListed" Type="Boolean" />
<ext:ModelField Name="selected" Type="Boolean" />

</Fields>
</ext:Model>
</Model>

</ext:Store>
</Store>
<ColumnModel ID="ColumnModel2" runat="server">
<Columns>

<ext:Column ID="Column1" runat="server" Text="Product" DataIndex="productName" Flex="1">
</ext:Column>

<ext:SummaryColumn ID="SummaryColumn1" runat="server" Text="Amount" Width="90" DataIndex="investAmount" SummaryType="Sum">
<SummaryRenderer Handler="return Ext.util.Format.number(value, '0,000.00');" ></SummaryRenderer>

</ext:SummaryColumn>
<ext:Column ID="Column5" runat="server" Text="Source" DataIndex="source" Width="80">
</ext:Column>
<ext:CheckColumn ID="isListedCol" runat="server" Text="Listed" DataIndex="isListed" Width="40" >
</ext:CheckColumn>


<ext:Column ID="Column3" runat="server" Text="Product Type" Width="90" DataIndex="productType">

</ext:Column>
</Columns>
</ColumnModel>
<Features>
<ext:Summary ID="Summary2" runat="server" />
</Features>
<SelectionModel>
<ext:CheckboxSelectionModel ID="ExtInvSelectionModel" runat="server" Mode="Multi" >
<Listeners>
<SelectionChange Handler="#{DirectMethods}.updateExtInvSelection();" Buffer="1500"></SelectionChange>
</Listeners>
</ext:CheckboxSelectionModel>
</SelectionModel>
<Buttons>
<ext:Button Icon="Add" ID="Button1" Text="Add New" runat="server" >
<Listeners>
<%-- <Click Handler="#{winExistingInvestmentsItem}.show()" />--%>
<Click Handler="#{DirectMethods}.showExistingInvestmentItemWin()" />

</Listeners>

</ext:Button>
<ext:Button Icon="Pencil" ID="Button2" Text="Edit" runat="server" ></ext:Button>
<ext:Button Icon="Delete" ID="Button3" Text="Remove Selected" runat="server" >

<DirectEvents>
<Click OnEvent="ExtInvDelete_Click">
<EventMask ShowMask="true" />
</Click>
</DirectEvents>

</ext:Button>

</Buttons>
</ext:GridPanel>

Daniil
Jul 20, 2012, 4:46 PM
Thanks for the POST collection (I wanted to request it as well) and the sample.

Regarding the POST collection.


this.ConfigID = "ucPCPanel_invPanel_ExtInvSelectionModel"

which is the ID of the SelctionModel, and which has the value:

val = "[{"

I can't see the "ucPCPanel_invPanel_ExtInvSelectionModel" key in the post collection. Can you confirm there is no such key?

Also could you replace

_VIEWSTATE=<all long text here>
with just

__VIEWSTATE=...

Just its value is not helpful, but covers about 8 (!) screens.

Regarding the sample.

Unfortunately, it didn't help to reproduce the problem.

CarpFisher
Jul 23, 2012, 7:29 AM
Hi

I've removed all the data for the viewstate. The ID:
ucPCPanel_invPanel_ExtInvSelectionModel is in the code but it looks like that because I used that inside an user control ASCX and it changed the prefix the ID with the parent components.....

I think the most important thing is how can an incomplete json object in the variable....

Chris

Daniil
Jul 23, 2012, 8:20 AM
I think the most important thing is how can an incomplete json object in the variable....


Yes, absolutely, but, repeat myself, I just did not see that in the post collection. Now I have found, there is just a white space in ID which doesn't allow to find that using the browser search.

I have no idea for now why it might happen.

Maybe this technique could help you to prepare a sample.
http://forums.ext.net/showthread.php?13672&p=56687&viewfull=1#post56687

You could replace any private data with some dummy data.

CarpFisher
Jul 26, 2012, 11:54 AM
after struggling for days and many sleepless nights I managed to trim down 99% of my code to the following files:

default.aspx


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

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register TagPrefix="uc" TagName="PCPanel" Src="~/PortforlioConstructionPanel.ascx" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>

</head>
<body>
<form id="form1" runat="server">

<ext:ResourceManager ID="ResourceManager1" runat="server" />


<ext:Viewport ID="Viewport1" runat="server" Layout="border">


<Items>



<ext:Panel ID="pnlMain" runat="server" Region="Center" Border="false" Layout="FitLayout" >
<Items>
<ext:Panel ID="pnlPCMain" runat="server" Visible="true" Layout="FitLayout">
<Content>
<uc:PCPanel runat="server" ID="ucPCPanel" />
</Content>
</ext:Panel>

</Items>




</ext:Panel>

</Items>
</ext:Viewport>

</form>
</body>
</html>




ClientProfileControl.ascx


<%@ Control Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
var qList = new[] {
new {
FullName="10",
clientID="a",

clientCIF="b"

},
new {
FullName="2",
clientID="b",

clientCIF="c"
},
new {
FullName="3",
clientID="d",

clientCIF="e"
}
};

this.Store3.Data = qList;



}

[DirectMethod(ViewStateMode = Ext.Net.ViewStateMode.Enabled)]
public void saveClientProfile()
{


MessageBus.Default.Publish("App.Change.ClientProfile", "1");
X.Msg.Notify("", "User:" + cboClientName.Text + " Loaded Successfully").Show();




}


</script>



<ext:FormPanel
ID="FormPanel1"
runat="server"
Title="Client Details"
Collapsible="true"
BodyPadding="10"
>
<Items>


<ext:ComboBox ID="cboClientName"
FieldLabel="User Name"
runat="server"
DisplayField="FullName"
ValueField="clientID"
TypeAhead="false"
Width="570"
PageSize="10"
HideBaseTrigger="true"
MinChars="1"
AllowBlank="false" >
<ListConfig LoadingText="Searching...">
<ItemTpl ID="ItemTpl1" runat="server">
<Html>
<div class="search-item">
<h3><span>{FullName}</span></h3>
({clientCIF})
</div>
</Html>
</ItemTpl>
</ListConfig>

<Store>
<ext:Store ID="Store3" runat="server" AutoLoad="false">

<Model>
<ext:Model ID="Model3" runat="server">
<Fields>
<ext:ModelField Name="FullName" />
<ext:ModelField Name="clientID" />
<ext:ModelField Name="clientCIF" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>

</ext:ComboBox>



</Items>
<Buttons>

<ext:Button ID="btnCreate" runat="server" Text="Create Profile" >
<Listeners>
<Click Handler="#{DirectMethods}.saveClientProfile({
eventMask: {
showMask: true
}
});" ></Click>
</Listeners>
</ext:Button>


</Buttons>

</ext:FormPanel>

<ext:Hidden runat="server" ID="hdnClientID" Text="" >
</ext:Hidden>



InvestmentControl.ascx

<%@ Control Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
[DirectMethod]
public void loadProductList()
{
loadProposedProducts();
loadExistingInvestments();

}

[DirectMethod]
public void loadProposedProducts()
{

Random r = new Random();

var qList = new[] {
new {
proposedProductID="1",
productName="a",
investAmount=r.Next(100),
productType="b",
investmentType="d",
selected=true
},
new {
proposedProductID="2",
productName="f",
investAmount=r.Next(100),
productType="g",
investmentType="h",
selected=true
},
new {
proposedProductID="3",
productName="i",
investAmount=r.Next(100),
productType="j",
investmentType="k",
selected=false
}
};


this.strProposedInv.Data = qList;

this.strProposedInv.DataBind();

ProposedInvSelectionModel.SelectedRows.Clear();



if (qList != null)
{
foreach (var p in qList.Where(o => o.selected == true))
{
ProposedInvSelectionModel.SelectedRows.Add(new SelectedRow(p.proposedProductID));
}

}
ProposedInvSelectionModel.UpdateSelection();


if (qList.Count() > 0)
{
try
{
Ext.Net.Panel p = this.Parent.Parent as Ext.Net.Panel;
p.Icon = Icon.Accept;
}
catch
{

}
}
else
{
try
{
Ext.Net.Panel p = this.Parent.Parent as Ext.Net.Panel;
p.Icon = Icon.Cancel;
}
catch
{

}
}


}


[DirectMethod]
public void loadExistingInvestments()
{

Random r = new Random();

var qList = new[] {
new {
objectID="1",
productName="a",
investAmount=r.Next(100),
productType="b",
investmentType="d",
selected=true
},
new {
objectID="2",
productName="f",
investAmount=r.Next(100),
productType="g",
investmentType="h",
selected=true
},
new {
objectID="3",
productName="i",
investAmount=r.Next(100),
productType="j",
investmentType="k",
selected=false
}
};



this.strExtInv.Data = qList;

this.strExtInv.DataBind();


ExtInvSelectionModel.SelectedRows.Clear();


if (qList != null)
{
foreach (var p in qList.Where(o => o.selected == true))
{
ExtInvSelectionModel.SelectedRows.Add(new SelectedRow(p.objectID));

}

}
ExtInvSelectionModel.UpdateSelection();


}


[DirectMethod()]
public void publish()
{

MessageBus.Default.Publish("App.Change.ClientProfile", "1");


}

</script>

<ext:Panel ID="pnlInvControl" runat="server" Layout="FitLayout" >
<MessageBusListeners>
<ext:MessageBusListener Name="App.Change.ClientProfile" Handler="#{DirectMethods}.loadProductList();" />
</MessageBusListeners>

<Items>
<ext:portal runat="server" >
<Items>
<ext:PortalColumn runat="server" StyleSpec="padding:10px 5px 10px 10px" ColumnWidth="0.5" Layout="anchor" DefaultAnchor="100%" >
<Items>

<ext:Portlet ID="pltExtInv" runat="server" Title="Existing Investments" Padding="5" Height="450" >
<Items>
<ext:GridPanel ID="gdpExtInv" runat="server" Selectable="true" >

<View>
<ext:GridView ID="GridView1" runat="server" LoadMask="true" LoadingText="Loading..." />
</View>
<Store>
<ext:Store ID="strExtInv" runat="server" >

<Model>
<ext:Model ID="Model1" runat="server" IDProperty="objectID">
<Fields>

<ext:ModelField Name="objectID" />
<ext:ModelField Name="productName" />
<ext:ModelField Name="contractID" />
<ext:ModelField Name="investAmount" Type="Float" />
<ext:ModelField Name="productType" />
<ext:ModelField Name="source" />
<ext:ModelField Name="isListed" Type="Boolean" />
<ext:ModelField Name="selected" Type="Boolean" />

</Fields>
</ext:Model>
</Model>

</ext:Store>
</Store>
<ColumnModel ID="ColumnModel2" runat="server">
<Columns>

<ext:Column ID="Column1" runat="server" Text="Product" DataIndex="productName" Flex="1">
</ext:Column>

<ext:SummaryColumn ID="SummaryColumn1" runat="server" Text="Amount" Width="90" DataIndex="investAmount" SummaryType="Sum">
<SummaryRenderer Handler="return Ext.util.Format.number(value, '0,000.00');" ></SummaryRenderer>

</ext:SummaryColumn>
<ext:Column ID="Column5" runat="server" Text="Source" DataIndex="source" Width="80">
</ext:Column>
<ext:CheckColumn ID="isListedCol" runat="server" Text="Listed" DataIndex="isListed" Width="40" >
</ext:CheckColumn>


<ext:Column ID="Column3" runat="server" Text="Product Type" Width="90" DataIndex="productType">

</ext:Column>
</Columns>
</ColumnModel>
<Features>
<ext:Summary ID="Summary2" runat="server" />
</Features>
<SelectionModel>
<ext:CheckboxSelectionModel ID="ExtInvSelectionModel" runat="server" Mode="Multi" >

</ext:CheckboxSelectionModel>
</SelectionModel>

</ext:GridPanel>
</Items>
</ext:Portlet>




</Items>
</ext:PortalColumn>
<ext:PortalColumn runat="server" StyleSpec="padding:10px 10px 10px 5px" ColumnWidth="0.5" Layout="anchor" DefaultAnchor="100%">
<Items>
<ext:Portlet ID="pltNewInv" runat="server" Title="Proposed Investments" Padding="5" Height="450">
<Items>
<ext:GridPanel ID="gdpNewInv" runat="server" Selectable="true" >
<Store>
<ext:Store ID="strProposedInv" runat="server" >

<Model>
<ext:Model ID="mdlProposedProduct" runat="server" IDProperty="proposedProductID">
<Fields>

<ext:ModelField Name="proposedProductID" Type="String" />
<ext:ModelField Name="productName" Type="String" />
<ext:ModelField Name="contractID" Type="String"/>
<ext:ModelField Name="investAmount" Type="Float" />
<ext:ModelField Name="productType" Type="String"/>
<ext:ModelField Name="investmentType" Type="String"/>
<ext:ModelField Name="selected" Type="Boolean" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>

<ext:Column ID="Column2" runat="server" Text="Product" DataIndex="productName" Flex="1">
</ext:Column>
<ext:SummaryColumn runat="server" Text="Invest Amount" Width="100" DataIndex="investAmount" SummaryType="Sum">
<SummaryRenderer Handler="return Ext.util.Format.number(value, '0,000.00');" ></SummaryRenderer>

</ext:SummaryColumn>
<ext:Column ID="Column4" runat="server" Text="Product Type" Width="80" DataIndex="productType">

</ext:Column>
<ext:Column ID="Column6" runat="server" Text="Type" Width="60" DataIndex="investmentType">

</ext:Column>
</Columns>
</ColumnModel>
<Features>
<ext:Summary ID="Summary1" runat="server" />
</Features>
<SelectionModel>
<ext:CheckboxSelectionModel ID="ProposedInvSelectionModel" runat="server" Mode="Multi" >



</ext:CheckboxSelectionModel>
</SelectionModel>

</ext:GridPanel>
</Items>
</ext:Portlet>

</Items>
</ext:PortalColumn>
</Items>
</ext:portal>
</Items>
<Buttons>
<ext:Button Text="No Error here" runat="server">
<Listeners >
<Click Handler="#{DirectMethods}.publish();"></Click>
</Listeners>

</ext:Button>
</Buttons>
</ext:Panel>






PortforlioConstructionPanel.ascx


<%@ Control Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register TagPrefix="cpc" TagName="clientProfileControl" Src="~/ClientProfileControl.ascx" %>
<%@ Register TagPrefix="inc" TagName="investmentControl" Src="~/InvestmentControl.ascx" %>




<ext:TabPanel id="TabPanel2" layout="FitLayout" runat="server" activetabindex="0"
border="false">

<Items>

<ext:Panel ID="pnlClientProfile" runat="server" Title="Client Profile" BodyPadding="5" AutoScroll="true" >

<Content >
<cpc:clientProfileControl runat="server" ID="cpcPanel"/>

</Content>
</ext:Panel>

<ext:Panel ID="pnlInvestment" runat="server" Title="Wealth Review" Layout="FitLayout" Icon="Cog">
<Content >
<inc:investmentControl runat="server" ID="invPanel" />

</Content>
</ext:Panel>



</Items>
</ext:tabpanel>



To reproduce the error, just type a letter in the user name box, choose the first one from the downdown list, click "create profile" button. Then click on the "Wealth Review" tab once. Now click back on the "Client profile" tab and click on the "create profile" button again you will get that error.

It took me very very long time to pin point this up to this point and i think i can't reduce it further, as this error kind of appearing randomly with my full application. In this form it happen every time in IE8 and Chrome.

Thank you very very much for your help

Daniil
Jul 26, 2012, 1:28 PM
Thanks for the sample.



To reproduce the error, just type a letter in the user name box, choose the first one from the downdown list

I am getting the JavaScript error when type "a" and the dropdown list appears.


TypeError: url is undefined
return url + (url.indexOf('?') === -1 ? '?' : '&') + string;


Do not you get this error as well?

Please clarify what Ext.NET sources do you use?

CarpFisher
Jul 26, 2012, 2:00 PM
thanks for your quick reply :)

I didn't have that javascript error.

I compiled from the 2.1 source last week and the version number of the Ext.net.dll is 2.0.0.29664. looks like it is coming from SVN revision 4211.

is this what you looking for?

Daniil
Jul 26, 2012, 3:20 PM
Strange that you are not getting the error.

I think you should replace:

this.Store3.Data = qList;
with

this.Store3.DataSource = qList;
this.Store3.DataBind();
and set up

QueryMode="Local"
for the ComboBox.

Also the Page_Load code into this statement.

if (!X.IsAjaxRequest)
{
/* Page_Load code here */
}


Regarding the main problem.

I have simplified your sample a bit:)

Example

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

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

<script runat="server">
protected void SomeDirectEventHandler(object sender, DirectEventArgs e)
{

}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:TabPanel runat="server" Height="400" Width="400">
<Items>
<ext:Panel runat="server" Title="Tab 1">
<Items>
<ext:Button runat="server" Text="Click me and open the next tab" StandOut="true">
<Listeners>
<Click Handler="var grid = App.GridPanel1,
store = grid.getStore();
store.proxy.data = [{ test: '1' }];
store.load();
grid.getSelectionModel().selectedData= [{ recordID:'1' }];
grid.initSelectionData();" />
</Listeners>
</ext:Button>
</Items>
</ext:Panel>
<ext:Panel runat="server" Title="Tab 2">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button
runat="server"
Dock="Top"
Text="Click me"
OnDirectClick="SomeDirectEventHandler" />
</Items>
</ext:Toolbar>
</TopBar>
<Items>
<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server" IDProperty="test">
<Fields>
<ext:ModelField Name="test" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test" DataIndex="test" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" />
</SelectionModel>
</ext:GridPanel>
</Items>
</ext:Panel>
</Items>
</ext:TabPanel>
</form>
</body>
</html>


I would consider it a bug. We are investigating a possible fix.

Daniil
Jul 26, 2012, 6:59 PM
The issue has been fixed in the 2.1 branch.

Please update and re-test.

CarpFisher
Jul 27, 2012, 8:07 AM
Thank you so much for the fix and I've tested. The popup has now gone away for the selection(s) is(are) not highlighted. If you still have my example, if you click on the "wealth review" tab and click the "No error here" button, without selecting a client profile dropdown first, you should see how the entries are selected. However the selections are not highlighted if the loading is triggered by selecting a client profile.

Daniil
Jul 27, 2012, 9:18 AM
Setting up

DeferredRender="false"
for the TabPanel should solve the problem.

Though we will investigate a possibility to get it working with the default

DeferredRender="true"

Here is the example to reproduce.

Example

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

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

<script runat="server">
protected void BindAndSelect(object sender, DirectEventArgs e)
{
Store store = this.GridPanel1.GetStore();
store.DataSource = new object[]
{
new { test = "test1" },
new { test = "test2" },
new { test = "test3" },
};
store.DataBind();

RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
sm.SelectedRows.Add(new SelectedRow("test2"));
sm.UpdateSelection();
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:TabPanel runat="server" Height="400" Width="400">
<Items>
<ext:Panel runat="server" Title="Tab 1">
<Items>
<ext:Button
runat="server"
Text="Click me and open the next tab"
StandOut="true"
OnDirectClick="BindAndSelect" />
</Items>
</ext:Panel>
<ext:Panel runat="server" Title="Tab 2">
<Items>
<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server" IDProperty="test">
<Fields>
<ext:ModelField Name="test" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test" DataIndex="test" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" />
</SelectionModel>
</ext:GridPanel>
</Items>
</ext:Panel>
</Items>
</ext:TabPanel>
</form>
</body>
</html>

CarpFisher
Jul 27, 2012, 9:35 AM
Thanks! The selection is working, however, I've got a listener of the SelectionChange, like the following, not firing anymore after I changed to DeferredRender="false"


<SelectionModel>
<ext:CheckboxSelectionModel ID="ExtInvSelectionModel" runat="server" Mode="Multi" >
<Listeners>
<SelectionChange Handler="#{DirectMethods}.updateExtInvSelection();" Buffer="1500"></SelectionChange>
</Listeners>
</ext:CheckboxSelectionModel>
</SelectionModel>

Is that the side effect of DeferredRender?

Daniil
Jul 27, 2012, 10:34 AM
It fires for me in the example below.

Example

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

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

<script runat="server">
protected void BindAndSelect(object sender, DirectEventArgs e)
{
Store store = this.GridPanel1.GetStore();
store.DataSource = new object[]
{
new { test = "test1" },
new { test = "test2" },
new { test = "test3" },
};
store.DataBind();

RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
sm.SelectedRows.Add(new SelectedRow("test2"));
sm.UpdateSelection();
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:TabPanel
runat="server"
Height="400"
Width="400"
DeferredRender="false">
<Items>
<ext:Panel runat="server" Title="Tab 1">
<Items>
<ext:Button
runat="server"
Text="Click me and open the next tab"
StandOut="true"
OnDirectClick="BindAndSelect" />
</Items>
</ext:Panel>
<ext:Panel runat="server" Title="Tab 2">
<Items>
<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server" IDProperty="test">
<Fields>
<ext:ModelField Name="test" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test" DataIndex="test" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server">
<Listeners>
<SelectionChange Handler="alert('SelectionChange');" />
</Listeners>
</ext:RowSelectionModel>
</SelectionModel>
</ext:GridPanel>
</Items>
</ext:Panel>
</Items>
</ext:TabPanel>
</form>
</body>
</html>

CarpFisher
Jul 27, 2012, 12:43 PM
Thanks. I've used the your sample code but if you change RowSelectionModel to CheckboxSelectionModel then the event not going to fire....

Daniil
Jul 27, 2012, 1:38 PM
Both issues have been fixed in SVN, please update.

Please note that if you call the UpdateSelection method for the not rendered GridPanel the SelectionChange will be fired when that GridPanel will be rendered.

CarpFisher
Jul 27, 2012, 2:49 PM
Thank you very much. It seems to be working!!