PDA

View Full Version : [CLOSED] Binding problem with <ext:Store>



aditya
Feb 17, 2014, 3:04 PM
In following DataView, I try to bind StoreActivities with code as follows,


using (CandidateEntities context = new CandidateEntities())
{
Guid candidateGuid = new Guid(candidateId);
var results = from p in context.Activities
where p.CandidateId == candidateGuid
select p.Description;

if (results.ToList().Any())
{
StoreActivities.DataSource = results.ToList();
StoreActivities.DataBind();
}
}

The results.ToList() contain some objects of type string. Which is fine, I have checked in debugger. After above DataBind(), listener abc(str) is called, which contains no data. What would be the problem?



<ext:Panel ID="Panel5" runat="server" Region="Center" Title="Activities">
<Items>
<ext:DataView runat="server" Padding="6" DisableSelection="true" Width="450">
<Store>
<ext:Store ID="StoreActivities" runat="server">
<Model>
<ext:Model ID="ModelActivity" runat="server">
<Fields>
<ext:ModelField Name="Description"/>
</Fields>
</ext:Model>
</Model>
<Listeners>
<Load Handler="abc(this);"></Load>
</Listeners>
</ext:Store>
</Store>
<ItemTpl>
<Html>
<tpl if="!editing">
<div style="position:relative; border: solid gray 1px; padding:6px; margin-bottom:6px;">
<p>Description: {Description}</p>
<div class="edit-button" style="position:absolute; right: 10px; bottom:10px;"></div>
</div>
</tpl>

<tpl if="editing">
<div style="position:relative; border: solid gray 1px; padding:6px; margin-bottom:6px;">
<p>{TextField}</p>
<div class="edit-button" style="position:absolute; right: 10px; bottom:35px;"></div>
<div class="cancel-button" style="position:absolute; right: 10px; bottom:10px;"></div>
</div>
</tpl>
</Html>
</ItemTpl>
<Plugins>
<ext:ComponentView runat="server">
<Items>
<ext:ViewItem Selector="div.edit-button" Tag="editing">
<Component>
<ext:Button
runat="server"
Icon="NoteEdit"
Handler="var record = this.record, editing = record.get('editing'); record.set('editing', !editing); if (editing) {record.commit(true);} "
/>
</Component>
</ext:ViewItem>

<ext:ViewItem Selector="div.cancel-button">
<Component>
<ext:Button runat="server" Icon="Decline" Text="Cancel" Handler="this.record.reject();" />
</Component>
</ext:ViewItem>

<ext:ViewItem Value="TextField" BoundField="Description">
<Component>
<ext:TextField runat="server" FieldLabel="Description" />
</Component>
</ext:ViewItem>
</Items>
<Listeners>
<BeforeComponentBind Handler="if(item.tag == 'editing') {component.text = record.data.editing ? 'Save' : 'Edit';}" />
</Listeners>
</ext:ComponentView>
</Plugins>
</ext:DataView>
</Items>
</ext:Panel>

Daniil
Feb 17, 2014, 3:32 PM
Hi @aditya,

Please wrap the code in [CODE] tags. Please do not create a new post. Just edit the existing one.

aditya
Feb 18, 2014, 5:23 AM
Hi @aditya,

Please wrap the code in [CODE] tags. Please do not create a new post. Just edit the existing one.

In following DataView, I try to bind StoreActivities with code as follows,



using (CandidateEntities context = new CandidateEntities())
{
Guid candidateGuid = new Guid(candidateId);
var results = from p in context.Activities
where p.CandidateId == candidateGuid
select p.Description;

if (results.ToList().Any())
{
StoreActivities.DataSource = results.ToList();
StoreActivities.DataBind();
}
}


The results.ToList() contain some objects of type string. Which is fine, I have checked in debugger. After above DataBind(), listener abc(str) is called, which contains no data. What would be the problem?




<ext:Panel ID="Panel5" runat="server" Region="Center" Title="Activities">
<Items>
<ext:DataView runat="server" Padding="6" DisableSelection="true" Width="450">
<Store>
<ext:Store ID="StoreActivities" runat="server">
<Model>
<ext:Model ID="ModelActivity" runat="server">
<Fields>
<ext:ModelField Name="Description"/>
</Fields>
</ext:Model>
</Model>
<Listeners>
<Load Handler="abc(this);"></Load>
</Listeners>
</ext:Store>
</Store>
<ItemTpl>
<Html>
<tpl if="!editing">
<div style="position:relative; border: solid gray 1px; padding:6px; margin-bottom:6px;">
<p>Description: {Description}</p>
<div class="edit-button" style="position:absolute; right: 10px; bottom:10px;"></div>
</div>
</tpl>

<tpl if="editing">
<div style="position:relative; border: solid gray 1px; padding:6px; margin-bottom:6px;">
<p>{TextField}</p>
<div class="edit-button" style="position:absolute; right: 10px; bottom:35px;"></div>
<div class="cancel-button" style="position:absolute; right: 10px; bottom:10px;"></div>
</div>
</tpl>
</Html>
</ItemTpl>
<Plugins>
<ext:ComponentView runat="server">
<Items>
<ext:ViewItem Selector="div.edit-button" Tag="editing">
<Component>
<ext:Button
runat="server"
Icon="NoteEdit"
Handler="var record = this.record, editing = record.get('editing'); record.set('editing', !editing); if (editing) {record.commit(true);} "
/>
</Component>
</ext:ViewItem>

<ext:ViewItem Selector="div.cancel-button">
<Component>
<ext:Button runat="server" Icon="Decline" Text="Cancel" Handler="this.record.reject();" />
</Component>
</ext:ViewItem>

<ext:ViewItem Value="TextField" BoundField="Description">
<Component>
<ext:TextField runat="server" FieldLabel="Description" />
</Component>
</ext:ViewItem>
</Items>
<Listeners>
<BeforeComponentBind Handler="if(item.tag == 'editing') {component.text = record.data.editing ? 'Save' : 'Edit';}" />
</Listeners>
</ext:ComponentView>
</Plugins>
</ext:DataView>
</Items>
</ext:Panel>

Daniil
Feb 18, 2014, 7:14 AM
Could you, please, re-read my post?

Please wrap the code in [CODE] tags. Please do not create a new post. Just edit the existing one.

aditya
Feb 18, 2014, 9:36 AM
please close this.