Hello,
I have a simple WebDataMenu and for some action I want a postback and other no postback
I use the NavigateURL property to define the new page
But in all cases, I alwaws have a postback
I don't want to disable postback for all item ans manage by myself the postback
Is there a way to do want I want ?
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
DataMenuItem rootItem = WebDataMenu1.Items.Add("Main menu", "Main");
DataMenuItem item1 = new DataMenuItem();
item1.Text =
"NavigateUrl";
item1.Value =
"ValSub1";
item1.NavigateUrl =
"http://www.microsoft.com";
item1.Target =
"blank";
rootItem.Items.Add(item1);
DataMenuItem item2 = new DataMenuItem();
item2.Text =
"PostBack";
item2.Value =
"ValSub2";
item2.Key =
rootItem.Items.Add(item2);
}
protected void ServerAction(object sender, DataMenuItemEventArgs e)
and aspx
function NoPostBack(sender, e) {
var itemMenu = e.getItem();
alert(itemMenu.get_valueString());
if (itemMenu.get_valueString() == '')
e.set_cancel(
true);
<ig:WebDataMenu ID="WebDataMenu1" runat="server" Height="39px" Width="132px" OnItemClick="ServerAction">
<AutoPostBackFlags ItemClick="On" ItemSelected="Off" />
<GroupSettings Orientation="Horizontal" />
<ClientEvents ItemClick="NoPostBack" />
</ig:WebDataMenu>
Thank you very much for your help
Romain
if I use e.set_cancel(true) in the javascript for my item2 with no postback, the navigateurl is never called
I was able to see the behavior you described. I have attached the issue with our developers in our tracking system, with an issue ID of # 139640. This development issue will be assigned to a developer to research for a fix, workaround, or other resolution. If some other resolution is reached, I will update this forum thread with more details on this.
I hope this helps.
Hi Romain,
When event is canceled, then all actions related to event are canceled too. That includes not only possible postback, but possible navigation too.
The eventArgs in current version of ItemClicked fails to expose postback flag. New property [get/set_postBack() methods] was added to event and coming service releases will contain that. That property (value of flag-parameter) can be checked or modified.
In current version of WebDataMenu applicaion may get around by using internal variable _props[1], which contains value of postback-flag. The value supports following flag-numbers:
0-no postback1-full postback2-internal asynchronous postback
Below is example with _props:
function NoPostBack(sender, e) { var itemMenu = e.getItem(); // condition to cancel postback to server, but keep possible navigation if (itemMenu.get_valueString()) e._props[1] = 0;}
Thank you Viktor,
It is working very well as I want
The propblem is that is not a clean method, if you change the props list in a next release, I need to have a new solution
Can you provide a server method to do that ? Or automatically disable postback when the navigateurl is set
Regards,
It is not possible to implement logic of your application on server. Because if server gets event from an item-click, then it means that postback already happened and there is nothing to cancel or modify dynamically. In order to configure similar on server, each DataMenuItem must have its own override for AutoPostBackFlags, so application might use that property instead of top-level AutoPostBackFlags. There is no plans to add that property to DataMenuItem.
Note: the _props variable of events exposed by any Infragistics.Web.UI controls is not going to be renamed or removed. Sure its direct usage is not clean and you may wait for official service release and use public e.set_postBack(0). That method is nothing more than a wrapper for e._props = 0;//value