Feb 12, 2011, 2:39 AM
[CLOSED] Rerun template on the fly
I need to rerun a template on the fly and I can't use direct events because this is being auto loaded into a tab.
I want to be able to click the button in the top bar and have it change a javascript variable. Then reload dataview with the template taking into account the value for a javascript variable used in an if condition.
I've also tried removing the if statement from the template and hiding the div with the checkbox and then showing it again when the button is clicked. But that doesn't work well either. The code below doesn't seem to help and paging seems to reset everything anyway.
I want to be able to click the button in the top bar and have it change a javascript variable. Then reload dataview with the template taking into account the value for a javascript variable used in an if condition.
<tpl if="AllowDelete == true">
<div><input type="checkbox" name="delPhoto" value="{id}" /></div>
</tpl>
I've pretty much taken your photos dataview example and used it, but i need a way to delete photos. I was thinking about dragging and dropping into a panel to delete, but i thought this would be easier. I've also tried removing the if statement from the template and hiding the div with the checkbox and then showing it again when the button is clicked. But that doesn't work well either. The code below doesn't seem to help and paging seems to reset everything anyway.
var elems = Ext.query("input[name=delPhoto]");
for(i=0; i<elems.length; i++) {
elems[i].parentElement.style.display = "block";
}
Is this possible?<script>
var AllowDelete = false;
</script>
<ext:Panel ID="plnPhotosCenterLayout" runat="server" Border="false" Layout="fit">
<Items>
<ext:Panel
runat="server"
ID="plnPhotosImagePanel"
Layout = "fit"
Title="Photos">
<Items>
<ext:DataView ID="dvPhotos"
StoreID="storePhoto"
runat="server"
AutoHeight = "true"
MultiSelect="true"
ItemSelector="div.thumb-wrap"
<Template ID="Template1" runat="server">
<Html>
<tpl for=".">
<div class="thumb-wrap">
<div class="thumb">
<a href='{image}' title='{name}'>
<img src="{thumb}" title="{name}"></a></div>
<span class="x-editable">{name}</span>
<tpl if="AllowDelete == true">
<div><input type="checkbox" name="delPhoto" value="{id}" /></div>
</tpl>
</div>
</tpl>
<div class="x-clear"></div>
</Html>
</Template>
</ext:DataView>
</Items>
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="btnDeleteSelected" runat="server" Text="Delete Selected Photos" Icon="Delete">
<Listeners>
<Click Handler="AllowDelete=true; storePhoto.reload(); dvPhotos.refresh();" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:Panel>
I left out the store because it's not really relevant and i wanted to keep this as short as possible.
Last edited by Daniil; Feb 12, 2011 at 4:22 PM.
Reason: [CLOSED]