- Home
- Forum
- ASP.NET MVC
- Duplicate Filds in Grid
Duplicate Filds in Grid
Good afternoon
I'm using a grid with editing and must ensure that the column with the name of theperson does not allow duplicate names.
If the user attempts to put duplicate name, should be shown a message that this is not allowed
How can I do that?
SIGN IN To post a reply.
3 Replies
PK
Prasanna Kumar Viswanathan
Syncfusion Team
September 30, 2016 06:12 AM UTC
Hi Guilherme,
Thanks for contacting Syncfusion support.
We have already discussed about this requirement in the below knowledgebase documentation.
Refer the above documentation and still if you face any issue, please get back to us.
Regards,
Prasanna Kumar N.S.V
GD
Guilherme de Alvarenga
September 30, 2016 12:23 PM UTC
Good day, I had tried to use this example, but I couldn't make it work.
This morning, I decided the issue as follows:
col
.Field(c => c.Description)
.ValidationRules(v => v
.AddRule("minhaValidaçãoObrigatório", 0)
.AddRule("minhaValidaçãoDeMaior50", 50)
.AddRule("messages", "{required:'" + Resource.ExpenseTypesListViewModel_DescriptionValidation + "'}")
)
.IsIdentity(true)
.Priority(1)
.Add();
------------------------------------------------
function begin(args) {
if (args.requestType == "save") {
$("#Editing").ejWaitingPopup("show");
var findDuplicate = false;
var Description = this.model.columns[1].field;
for (var i = 0; i < args.model.currentViewData.length; i++) {
if (args.model.currentViewData[i].Description == args.data[Description]) {
args.cancel = true;
$("#DuplicateFieldDescriptionDialog").ejDialog("open");
$("#" + this._id + "_dialogEdit").ejDialog("close");
findDuplicate = true;
break;
}
}
if (findDuplicate) {
return;
} else {
var addToGrid = {};
addToGrid.Description = this.model.columns[1].field;
addToGrid.CreatorRE = this.model.columns[6].field;
var dateTimeNow = moment(moment()).format('DD/MM/YYYY HH:mm:ss');
args.data[addToGrid.CreatorRE] = loggedUserRE;
}
}
}
PK
Prasanna Kumar Viswanathan
Syncfusion Team
October 3, 2016 01:48 PM UTC
Hi Guilherme,
We checked with your code example in our sample and the alert message has been displayed when we try to save the duplicate name.
Find the code example and sample:
|
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowSorting()
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
-----------------------------
.Columns(col =>
{
---------------------------
})
.ClientSideEvents(eve => eve.ActionBegin("begin"))
)
<script>
function begin(args) {
if (args.requestType == "save") {
$("#FlatGrid").ejWaitingPopup("show");
var findDuplicate = false;
var Description = this.model.columns[1].field;
for (var i = 0; i < args.model.currentViewData.length; i++) {
if (args.model.currentViewData[i].CustomerID == args.data[Description]) {
args.cancel = true;
alert("Not working");
findDuplicate = true;
break;
}
}
if (findDuplicate) {
return;
}
}
}
</script>
|
To find the root cause of the issue we need the following details.
1. Do you face any script error in the console? If Yes, Share the stackrace of an issue.
2. In the actionBegin event you have shown the waiting popup. So, do you need to hide the waiting-pop up after alert message is shown?
3. Share the screenshot of an issue.
4. If possible, replicate the issue in the attached sample.
Regards,
Prasanna Kumar N.S.V
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
GD Guilherme de Alvarenga
- Sep 29, 2016 07:56 PM UTC
- Oct 3, 2016 01:48 PM UTC