PDA

View Full Version : [CLOSED] Question about component loader



feanor91
Jan 22, 2013, 1:27 PM
Hello

I begin to play with component loader as it is a powerfull way to add component to other one, but I have a question.

I made a tabpanel with 2 tabs. Second tabs will be loaded by a component loader on first activation BUT i want to clear this tab and reload if I change a parameter.

See this code :



<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TestComponentLoader.aspx.vb" Inherits="VisualManagement.TestComponentLoader" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!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 runat="server">
<title></title>
<script language="javascript" type="text/javascript">
clearPanel = function ()
{
App.tabHistorique.clear();
}

</script>
</head>
<body>


<form id="form1" runat="server">
<ext:ResourceManager runat="server" ID="ResourceManager">
</ext:ResourceManager>

<ext:Panel runat="server" Width="500" Height="500" Layout="FitLayout">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:NumberField
ID="txtToSeek"
runat="server"
FieldLabel="Value to seek"
AllowBlank="false"
BlankText="mandatory."
LabelWidth="80">
</ext:NumberField>
<ext:Button runat="server" Text="clear Panel">
<Listeners>
<Click Handler="#{tabHistorique}.removeAll()"></Click>
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Items>
<ext:TabPanel ID="tabRMA" runat="server" Height="200" Width="350">
<Items>
<ext:Panel ID="tabLast" runat="server" Border="false" Layout="FitLayout" Title="Some stuff">
</ext:Panel>
<ext:Panel ID="tabHistorique" runat="server" Border="false" Title="Historique" Layout="FitLayout">
<Loader ID="Loader1" runat="server" Url="LoadHistorique.ashx" Mode="Component" >
<LoadMask ShowMask="true"></LoadMask>
<Params>
<ext:Parameter Name="RMA" Value="#{txtToSeek}.value" Mode="Raw"></ext:Parameter>
</Params>
</Loader>
</ext:Panel>
</Items>
</ext:TabPanel>
</Items>
</ext:Panel>
</form>
</body>
</html>


when txtToSeek change I want to update the second tab as the contents will depend of value in txtToSeek field.

The ashx that made component (very basic at this time and sorry for vb code)



Imports System.Web
Imports System.Web.Services
Imports Ext.Net

Public Class LoadHistorique
Implements System.Web.IHttpHandler

Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim MyComponents As List(Of AbstractComponent) = New List(Of AbstractComponent)

Dim myTab As New TabPanel

For i As Integer = 0 To 10
Dim myPanel As New Panel
With myPanel
.Title = "Panel" + i.ToString
End With
myTab.Add(myPanel)
Next

context.Response.ContentType = "application/json"

ComponentLoader.Render(myTab)


End Sub

ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property

End Class


Another question, how can I get RMA param in handler? I look at context data but found nothing so far. EDIT : found : My.Request.Form(0) conatins my param.

EDIT 2 I found solution here : http://forums.ext.net/showthread.php?18879-CLOSED-How-to-reset-panel-when-autoloading-a-partialview

Daniil
Jan 22, 2013, 4:22 PM
Hi @feanor91,

So, can we just mark the thread as closed?

Vladimir
Jan 22, 2013, 4:24 PM
Please note that if you set RemoveAll="true" for Loader then previous widgets inside container will be deleted automatically
To intiate reloading when text field is change you can use Change event of the field


<Change Handler="#{tabHistorique}.getLoader().load();"/>

feanor91
Jan 22, 2013, 4:57 PM
Danii : yes you can
Vladimir: ok, I will check