PDA

View Full Version : [CLOSED] V2.1 RemoteValidation on PlugIn Editor Help



Aurelio
Aug 26, 2012, 11:09 PM
Hi..i need to remotevalidation the field on blur in a editor mode..where is the code:

1)Push the button load, is define the grid a runtime
2)Select the row in the grid and push edit or double clik on a row

Then blur the field, i need to validate the value and if is not valid, disable the button Update.

Then edit, i retrive an error: "The control with ID 'txt38' not found"



<%@ Page Language="C#" AutoEventWireup="true" Inherits="ARWebRevolution.WebForm1" %>

<%@ 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>

</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" Namespace="" IDMode="Static" >
</ext:ResourceManager>
<ext:Store ID="StoreTaglie" runat="server">
<Model>
<ext:Model ID="Model1" runat="server" />
</Model>
</ext:Store>
<ext:Viewport ID="ViewportFornitori" runat="server" Layout="BorderLayout" >
<Items>
<ext:FormPanel ID="FormPanelFornitore" runat="server" ButtonAlign="Right" Cls="formMargins"
BodyPadding="5" Padding="3" Region="Center" DefaultButton="ButtonSave" Title="Fornitore..."
Layout="AnchorLayout" AnchorVertical="100%" MinWidth="300" >
<FieldDefaults LabelWidth="90" />
<Items>
<ext:TextField ID="txtTaglie" runat="server" FieldLabel="Taglie" AnchorHorizontal="100%">
</ext:TextField>
<ext:GridPanel ID="GridPanelBarCod" runat="server" Anchor="0 -30" MarginSpec="5 5 0 5" StoreID="StoreTaglie" >
<ColumnModel ID="ColumnModelBarCode" >
</ColumnModel>
<Plugins>
<ext:RowEditing ID="RowEditingBarCode" runat="server" >
<Listeners>
<ValidateEdit Fn="validateBarCode" />

</Listeners>
</ext:RowEditing>
</Plugins>

</ext:GridPanel>
</Items>
<BottomBar>
<ext:Toolbar runat="server" ID="ToolBar1">
<Items>
<ext:Button ID="ButtonNew" runat="server" Text="Nuovo" Scale="Medium" IconUrl="Images/24/new24.png"
ToolTip="Crea una nuovao aliquota." ToolTipType="Title">
<DirectEvents>
<Click OnEvent="DefineGrid" />
</DirectEvents>
</ext:Button>
<ext:Button ID="ButtonEditTaglia" runat="server" Text="Edit" Icon="PageEdit" >
<Listeners>
<Click handler="editTaglia(GridPanelBarCod.getSelectionModel().get LastSelected());" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</BottomBar>
</ext:FormPanel>
</Items>
</ext:Viewport>

<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
txtTaglie.Text = "38,39,40,41";
}
}

protected void DefineGrid(object sender, DirectEventArgs e)
{
var taglie = txtTaglie.Text.ToString().Split(new char[] { ',' });

//StoreArtColTag.Model.Clear();
//GridPanelBarCod.SelectionModel.Clear();

StoreTaglie.AddField(new ModelField("ColId", ModelFieldType.Int));
StoreTaglie.AddField(new ModelField("ColDes", ModelFieldType.String));

foreach (string taglia in taglie)
{
StoreTaglie.AddField(new ModelField("Col" + taglia, ModelFieldType.String));
}
//StoreTaglie.RebuildMeta();
StoreTaglie.Insert(0, new { ColDes = "Green" });

GridPanelBarCod.ColumnModel.Columns.Clear();
GridPanelBarCod.ColumnModel.Columns.Add(new Column
{
DataIndex = "ColDes",
Text = "Colore",
Locked = true
});

foreach (string taglia in taglie)
{
var column = new Column();
column.DataIndex = "Col" + taglia;
column.Text = taglia;
column.Width = 120;
column.EmptyCellText = taglia;

var textField = new TextField();
textField.ID = "txt" + taglia;
textField.IsRemoteValidation = true;
textField.RemoteValidation.Validation += RemoteValidation_Validation;
textField.RemoteValidation.EventOwner = ValidationEventOwner.Field;
textField.RemoteValidation.ValidationEvent = "Blur";
column.Editor.Add(textField);

GridPanelBarCod.ColumnModel.Columns.Add(column);
//GridPanelBarCod.Editor.Add(textField);
}

//StoreArtColTag.DataBind();

var editTaglia = new ConfigItem()
{
Name = "editTaglia",
Value = "true",
Mode = ParameterMode.Raw
};
var editModeTaglia = new ConfigItem()
{
Name = "editModeTaglia",
Value = "Read",
Mode = ParameterMode.Value
};

var rowEditing = new RowEditing();
rowEditing.ID = "RowEditingBarCode";
rowEditing.AutoCancel = true;
rowEditing.SaveBtnText = "Salva";
rowEditing.CancelBtnText = "Annulla";

rowEditing.CustomConfig.Add(editTaglia);
rowEditing.CustomConfig.Add(editModeTaglia);

GridPanelBarCod.Plugins.Add(new RowEditing()
{
PluginId = "row",
SaveBtnText = "Salva"
});

GridPanelBarCod.Reconfigure();
}

protected void RemoteValidation_Validation(object sender, RemoteValidationEventArgs e)
{
TextField field = (TextField)sender;

if (field.Text == "Valid" || field.Text == "")
{
e.Success = true;
}
else
{
e.Success = false;
e.ErrorMessage = e.Value + e.Name;

}

}
</script>

<ext:XScript ID="XScript1" runat="server">
<script type="text/javascript">

function testBarCode(field) {
if (field.originalText != field.rawValue) {
field.originalText = field.rawValue;

}
};

//Modifica colore
var editTaglia = function (record) {
if (record != null) {

GridPanelBarCod.editingPlugin.startEdit(record, 0);
RowEditingBarCode.editModeTaglia = "Edit";
RowEditingBarCode.editTaglia = true;
}
};

//Valida l'inserimento dei dati
var validateBarCode = function () {

return true;
}
</script>
</ext:XScript>
</form>
</body>
</html>




Any help is appreciated

Thanks
Aurelio

Daniil
Aug 27, 2012, 5:29 AM
Hi,

A RemoteValidation event is a DirectEvent. As any DirectEvent it requires a control instance on server.

So, you should recreate the Editor control.

Also this scenario is not a common one. It is discussed here:
http://forums.ext.net/showthread.php?20226

Daniil
Aug 27, 2012, 12:05 PM
By the way, there is the following example you can be interested in.

<Ext.NET 2.1 sources root>\Ext.Net.Examples\Examples\GridPanel\Plugins\RowEd itor_Remote\Default.aspx

Aurelio
Aug 27, 2012, 2:17 PM
Hi..Daniil

Ok...rewrite the code with your example and let you know the result..

Thanks
Aurelio

Aurelio
Aug 27, 2012, 3:18 PM
Hi..Daniil

It's Fantastyc !!!!! Miticooo....work Ok

Many Many Thansk

Aurelio