Hide Primary key input for Syncfusion Grid

Posted: September 4, 2013 in Uncategorized

I ran into an issue using NHibernate + domain objects with the Syncfusion grid.
I am using an auto incremented [generated identity] integer primary key that NHibernate expects to be null when creating a new item.

With the syncfusion grid, the primary key is a required field on the “add new” form/dialog by default.
To avoid the requirement of supplying a value in the “add new” form, you can hide the parent div of the primary key input item by using the “OnActionSuccess” client event.

        .ClientSideEvents(events =>

Then the javascript function to hide the field from validation…
In this case, the field mapping is “Id”.

            function HideOnAdd(sender, args) {
                if (args.RequestType == 'AddNew') {
                    var gridObj = $('#GenericListGridEditDialog');
                    gridObj.find('#Id').parent().css('display', 'none');

If you are using a different edit method, the name of the form or dialog could be a different format.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s