PDA

View Full Version : [CLOSED] Field validation inside cellediting gridpanel



matrixwebtech
Jul 11, 2014, 4:13 PM
How to validate fields inside gridpanel with client side scripting ,fields inside editor.


X.Column()
.DataIndex("men")
.Text("Men")
.Editor(X.TextField()
.ID("txtMen")

.CustomConfig(cc => cc.Add(new ConfigItem { Name = "initQuery", Value = "Ext.emptyFn", Mode = ParameterMode.Raw }))
.AllowBlank(false)
)

Daniil
Jul 11, 2014, 6:01 PM
Hi @matrixwebtech,

Please describe what exactly you would like to do.

Do you mean that AllowBlank="false" is not working? It appears to be working for me.

matrixwebtech
Jul 11, 2014, 7:18 PM
Hi daniil

please look http://forums.ext.net/showthread.php?39211-CLOSED-Load-combobox-dynamically-inside-gridpanel-editorfield

here I design a gridpanel(on 1st post) with editor.I want to validate each field of each row on save button click.
I use allowblank = false but its not working on save button click then i write bellow script



.Listeners(l => l.Click.Handler = "return validation();")



<script type="text/javascript">
var validation = function () {

var grid = App.GridPanel1;
var j=0
grid.getStore().each(function (item) {
//Ext.MessageBox.alert(item);
//console.log(item.data)
//var json = JSON.parse(item.data);
j = j + 1;
var row = item.data,
column;

for (column in row) {
if (row.hasOwnProperty(column)) {
//console.log(column + " = " + row[column]);
if (length(row[column]) <= 0 || row[column] == "0") {
Ext.MessageBox.alert("Fill all field at row "+ j);
}
}
}

})



}
</script>

its validate the store but I not able to set a error message against the particular field which is blank and set focus to this control.can you please suggest me a best way to do this?

Daniil
Jul 12, 2014, 10:22 AM
A Column shares its Editor for all the rows. It means that there is the only ComboBox for all the rows. So, you won't be able to show an individual ComboBox for several rows of the same Column. I would say there is no built-in functionality to demonstrate visually the validation errors in a GridPanel. I would suggest you to try with a Column's Renderer. If a cell's value is not valid, then show an error in the cell.


but I not able to set a error message against the particular field which is blank and set focus to this control.

You could start editing programmatically on the cell of the specific row and column. The shown editor field should be validated according to its validation settings.

matrixwebtech
Jul 12, 2014, 2:21 PM
can you please some example of Column's Renderer

Daniil
Jul 12, 2014, 8:59 PM
I would say there is a Renderer used in the most of our GridPanel examples.