We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Default Values for new records

When adding a new record, is there any way to have certain fields come up with a default value?

6 Replies

AD Administrator Syncfusion Team September 22, 2006 06:51 AM UTC

Hi Mitch,

We are looking in to this and will get back to you soon.

Thanks,
A.Sivakumar


AD Administrator Syncfusion Team October 9, 2006 04:45 PM UTC

Hi Mitch,

I apologize, for the delay in getting back to you, We didn''t noticed this as unanswedred because of posted in the Grouping.Web Category, and you can acheive this behavior by handling the ''QueryCellStyleInfo'' Event.

The below code indicates specifying ''new value'' for the id column for the ''AddNew'' Row.

[c#]

protected void GGC_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.AddNewRecordFieldCell)
{
if (e.TableCellIdentity.Column.Name == "id")
{
e.Style.Text = "newID";
}
}
}

Let us know if you need more info

Thanks,
A.Sivakumar


AD Administrator Syncfusion Team October 9, 2006 04:45 PM UTC

Hi Mitch,

I apologize, for the delay in getting back to you, We didn''t noticed this as unanswedred because of posted in the Grouping.Web Category, and you can acheive this behavior by handling the ''QueryCellStyleInfo'' Event.

The below code indicates specifying ''new value'' for the id column for the ''AddNew'' Row.

[c#]

protected void GGC_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.AddNewRecordFieldCell)
{
if (e.TableCellIdentity.Column.Name == "id")
{
e.Style.Text = "newID";
}
}
}

Let us know if you need more info

Thanks,
A.Sivakumar


MT Minh Tran November 2, 2006 06:08 PM UTC

This seems like a very awkward way of handling default values. And the QueryCellStyleInfo event fires alot.

I tried to achieve this by setting the GridStyleInfo.Text property, but it blows up in the designer & when I try to run it.

Ie, I have a GridColumnDescriptor with the following:

GridColumnDescriptor2.Appearance.AddNewRecordFieldCell.CellType = "CheckBox";

GridColumnDescriptor2.Appearance.AddNewRecordFieldCell.Text = "True";

The designer shows an object reference not set to an instance of object NullReference exception.

Any idea why this wouldn't work?


AD Administrator Syncfusion Team November 4, 2006 11:59 AM UTC

Hi Minh,

We are looking in to this and will get back to you as soon as possible.

Thanks,
A.sivakumar


AD Administrator Syncfusion Team November 23, 2006 01:13 AM UTC

Hi Minh,

I apologize for the delay in getting back to you. Setting the CellTypes using Celltype of the columns will result in some erorrs in design time and also you will not have a option to handle this checkbox events easily. There will be more changes and modifications in our celltypes in first quarter of 2007. For now you can acheive similar behavior through templates easily.

You can place a checkbox control as ItemTemplate or EditItemTemplate inside the corresponding column, and can set this checkbox value to true or false.

Please have a look at this forum where, checkbox inside unbound columns are discussed, Checkbox inside Grid various scenarios. You can also use bounded column for this purpose.

let us know if you have any queries.

Best regards,
Siva

Loader.
Live Chat Icon For mobile
Up arrow icon