Hello,
I'm following the below post:
http://forums.ext.net/showthread.php?4635#post18204
However my values are not static and according to a value I have to load the values of this button menu control again.
How can I do that?
Thanks,
Gokce
Printable View
Hello,
I'm following the below post:
http://forums.ext.net/showthread.php?4635#post18204
However my values are not static and according to a value I have to load the values of this button menu control again.
How can I do that?
Thanks,
Gokce
Hi Gokce,
Please post a simplified .aspx sample demonstrating how you currently have the component configured.
Hello,
Basically I'm doing the following. I have to repopulate the category menu according to the selected company. I can do it in the page load if the event's (SelectCompany_Click) AutoPostBack property is set to true. However is there any way to make in the ajax event without post back?
Thanks,
gokce
Code:<script type="text/javascript">
var updateCategoryText=function(item,checked) {
var text=[];
item.parentMenu.items.each(function(item) {
if(item.checked) {
text.push(item.text);
}
});
if(text.length==0) {
<%= btnCategory.ClientID %>.setText("Select Categories");
} else {
<%= btnCategory.ClientID %>.setText(text.join(","));
}
};
</script>
<style type="text/css">
.checked-button .x-btn-center{
text-align:left !important;
}
</style>
<ext:Store runat="server" ID="store1">
<Reader>
<ext:JsonReader>
<Fields>
<ext:RecordField Name="clmn11" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:BorderLayout runat="server" ID="pageBorderLayout">
<North MarginsSummary="0 5 5 5">
<ext:Panel ID="searchPanel" runat="server"
Border="false" HideBorders="true" AutoHeight="true" BodyStyle="padding:5px;" Frame="true" Collapsible="true"
Title="Browse Company" Icon="Magnifier">
<Body>
<ext:Panel ID="searchOptionsPanel" runat="server" Border="false" HideBorders="true">
<Body>
<ext:FormLayout ID="formSearchOptions" runat="server" LabelWidth="150">
<ext:Anchor>
<ext:MultiField runat="server" FieldLabel="Company Info">
<Fields>
<ext:TextField ID="txtCompanyHostId" runat="server" Width="200" Note="Company Id" />
<ext:TextField ID="txtCompanyStructureId" runat="server" Width="200" Note="Structure Id" />
<ext:LinkButton runat="server" Text="Select Company" AutoPostBack="true">
<AjaxEvents>
<Click OnEvent="SelectCompany_Click" />
</AjaxEvents>
</ext:LinkButton>
</Fields>
</ext:MultiField>
</ext:Anchor>
<ext:Anchor>
<ext:MultiField runat="server" FieldLabel="Categories">
<Fields>
<ext:Button ID="btnCategory" runat="server" Text="Select Categories" MinWidth="200" CtCls="checked-button">
<Menu>
<ext:Menu ID="menuCategory" runat="server" Width="200">
</ext:Menu>
</Menu>
</ext:Button>
</Fields>
</ext:MultiField>
</ext:Anchor>
</ext:FormLayout>
</Body>
<Buttons>
<ext:Button ID="btnSearch" runat="server" Text="Browse" Icon="Magnifier" CausesValidation="true" Type="Submit">
<AjaxEvents>
<Click OnEvent="Browse_OnClick">
<EventMask ShowMask="true" Msg="Loading ..." />
</Click>
</AjaxEvents>
</ext:Button>
</Buttons>
</ext:Panel>
</Body>
</ext:Panel>
</North>
<Center MarginsSummary="0 5 0 5">
<ext:Panel ID="centerPanel" runat="server" Frame="true">
<Body>
<ext:Accordion ID="centerAccordionLayout" runat="server">
<ext:GridPanel runat="server" ID="grid1" StoreID="store1" Header="true" Title="Names" Collapsed="true" Icon="Group">
<ColumnModel runat="server" ID="listColumnModel1">
<Columns>
<ext:Column ColumnID="clmn11" Header="clmn11" DataIndex="clmn11" />
</Columns>
</ColumnModel>
</ext:GridPanel>
</ext:Accordion>
</Body>
</ext:Panel>
</Center>
</ext:BorderLayout>
Code:protected void Browse_OnClick(object sender, Coolite.Ext.Web.AjaxEventArgs e)
{
// some code
}
protected void SelectCompany_Click(object sender, AjaxEventArgs e)
{
menuCategory.Items.Clear();
if (!string.IsNullOrEmpty(txtCompanyHostId.Text.Trim()))
{
System.Collections.Generic.List<Entity.CodeValue> categories = Data.Category.Get_HostIDsByCompanyHostID(txtCompanyHostId.Text.Trim(), txtCompanyStructureId.Text.Trim());
foreach (Truvo.Web.ContentManagement.Entity.CodeValue category in categories)
{
Coolite.Ext.Web.CheckMenuItem item = new Coolite.Ext.Web.CheckMenuItem();
item.Text = category.Description;
item.Checked = false;
item.CheckHandler = "updateCategoryText";
item.Width = new System.Web.UI.WebControls.Unit(200);
item.Attributes.Add("key", category.Code);
item.HideOnClick = false;
menuCategory.Items.Add(item);
}
}
}
Hi,
At this moment you can add new items via javascript only
Code:Button1.menu.add(new Ext.menu.CheckItem({
text: 'text',
checked: false,
checkHandler: myHandler,
width:200,
hideOnClick: false
}));
Just a quick note here... adding Menu items from code-behind during an AjaxEvent will be possible with the upcoming v1.0 release.
Thanks for information. I'd like to ask if you have a scheduled date for version 1.0? It's important for us to make a schedule in our applications for enhancements and improvements. Looking forward to hearing from you.
Any news on this issue?
I'm trying the same thing, adding the items but i can't see them in the menu.
I've also tried using DataBind or Update methods on the menu control, but nothing.
Thanks!
Hi,
Here is an example.
Example
Code:<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Add(object sender, DirectEventArgs e)
{
Ext.Net.MenuItem item = new Ext.Net.MenuItem()
{
Text = "Dynamic item",
Icon = Icon.Add
};
this.Menu1.Items.Add(item);
this.Menu1.UpdateContent();
}
</script>
<!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>Ext.Net Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:Button runat="server" Text="Menu">
<Menu>
<ext:Menu ID="Menu1" runat="server">
<Items>
<ext:MenuItem Text="Static item" Icon="Add" />
</Items>
</ext:Menu>
</Menu>
</ext:Button>
<ext:Button runat="server" Text="Add" OnDirectClick="Add" />
</form>
</body>
</html>
Thanks Daniil!
Your example works, but if i try to add a checkmenuitem (not a menu item), with a checkHandler i get a javascript error.
Please provide a sample.