PDA

View Full Version : [CLOSED] ValidateEdit in EditGrid issue



capbarbell
May 10, 2013, 11:01 AM
HI Ext.net Team,

I tried to use Ext.MessageBox.confirm function of ValidateEdit event in EditGrid.

When I click "Yes" button, no event is triigered (need to trigger Edit event )

But same situation works in window.confirm

Do you have any idea?



<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
this.Store1.DataSource = this.Data;
this.Store1.DataBind();
}
}

private object[] Data
{
get
{
return new object[]
{
new object[] { "3m Co", 71.72, 0.02, 0.03, "9/1 12:00am" },
new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am" },
new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am" },
new object[] { "American Express Company", 52.55, 0.01, 0.02, "9/1 12:00am" },
new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, "9/1 12:00am" },
new object[] { "AT&T Inc.", 31.61, -0.48, -1.54, "9/1 12:00am" },
new object[] { "Boeing Co.", 75.43, 0.53, 0.71, "9/1 12:00am" },
new object[] { "Caterpillar Inc.", 67.27, 0.92, 1.39, "9/1 12:00am" },
new object[] { "Citigroup, Inc.", 49.37, 0.02, 0.04, "9/1 12:00am" },
new object[] { "E.I. du Pont de Nemours and Company", 40.48, 0.51, 1.28, "9/1 12:00am" }
};
}
}
</script>
<!DOCTYPE html>

<html>
<head runat="server">
<title></title>
<script type="text/javascript">
var confirmData = function () {
if (window.confirm('Are you sure?')) {
return true;
}
else {
return false;
}

}

var confirmDataWithExtConfirm = function () {
Ext.MessageBox.confirm('', 'Are you sure you?', function (btn) {
if (btn == 'yes') {
return true;
}
else {
return false;
}
});
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager runat="server" />
<ext:Store ID="Store1" runat="server" IDMode="Static" WarningOnDirty="false">
<Model>
<ext:Model ID="Model1" runat="server" IDProperty="_ModelId">
<Fields>
<ext:ModelField Name="company"/>
<ext:ModelField Name="price" Type="Float" />
<ext:ModelField Name="change" Type="Float" />
<ext:ModelField Name="pctChange" Type="Float" />
<ext:ModelField Name="lastChange" Type="Date" DateFormat="M/d hh:mmtt" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:GridPanel ID="MainGrid" runat="server" StoreID="Store1" Height="300" Region="Center">
<ColumnModel ID="MainColumnModel" runat="server">
<Columns>
<ext:Column runat="server" ID="colComment" Text="" Width="60" Align="Center">
<Commands>
<ext:ImageCommand HideMode="Display" CommandName="EditRow" Icon="ApplicationEdit" ToolTip-Text="Click to Edit" />
</Commands>
</ext:Column>
<ext:Column runat="server" ID="colcompany" DataIndex="company" Text="company" Width="80">
<Editor>
<ext:TextField ID="txtcompany" runat="server"/>
</Editor>
</ext:Column>
<ext:Column runat="server" ID="colprice" DataIndex="price" Text="company" Width="80"/>
<ext:Column runat="server" ID="colchange" DataIndex="change" Text="change" Width="80"/>
<ext:Column runat="server" ID="colpctChange" DataIndex="pctChange" Text="pctChange" Width="80"/>
<ext:DateColumn runat="server" ID="collastChange" DataIndex="lastChange" Text="lastChange" Width="80"/>
</Columns>
</ColumnModel>
<Plugins>
<ext:RowEditing ID="RowEditing1" runat="server" ClicksToMoveEditor="2" AutoCancel="false" >
<Listeners>
<CancelEdit Handler="" />
<Edit Handler="alert('Edit');" />
<ValidateEdit Handler="if(confirmData()){return true;}else{return false;}" />
</Listeners>
</ext:RowEditing>
</Plugins>
<View>
<ext:GridView ID="GridView1" runat="server" TrackOver="false" />
</View>
<Listeners>
<ItemClick Handler="return false;" />
<ItemDblClick Handler="return false;" />
</Listeners>
</ext:GridPanel>
</form>
</body>
</html>

6191

RCN
May 10, 2013, 11:27 AM
Please wrap all code samples in [CODE] tags.

Some more details are in our forums guidelines.
Forum Guidelines For Posting New Topics (http://forums.ext.net/showthread.php?3440)
More Information Required (http://forums.ext.net/showthread.php?10205)

capbarbell
May 11, 2013, 1:05 AM
Please wrap all code samples in [CODE] tags.

Some more details are in our forums guidelines.
Forum Guidelines For Posting New Topics (http://forums.ext.net/showthread.php?3440)
More Information Required (http://forums.ext.net/showthread.php?10205)

HI,

I had modified the contents, please take a look.
Thanks

Baidaly
May 11, 2013, 2:31 AM
Hello!

You cannot do that because Ext.MessageBox.confirm doesn't stop execution of JavaScript so ValidateEdit's handler always return true regardless user's choice. In this case you should use native JS window.confirm

Daniil
May 13, 2013, 5:36 AM
Hi,

Yes, a native confirm function can help.

Also please take a look at the following example.
http://examples2.ext.net/#/GridPanel/Plugins/RowEditor_Remote/

It should help you to achieve the requirement with an Ext.Msg.confirm.

capbarbell
May 14, 2013, 11:02 AM
Hi,

Yes, a native confirm function can help.

Also please take a look at the following example.
http://examples2.ext.net/#/GridPanel/Plugins/RowEditor_Remote/

It should help you to achieve the requirement with an Ext.Msg.confirm.

Hi Daniil,

Thank you. That was very helpful.