I have the following column in my grid
As you can see I have DefaultInsertValue set to True. However when I go to add a new record the checkbox isn't checked, can anyone think of any reason this may be happening? I should be able to set it to checked in my code but I would like to know what I am doing wrong with this.
<
telerik:GridCheckBoxColumn
DataField
=
"staffActive"
AutoPostBackOnFilter
=
"true"
ShowFilterIcon
=
"false"
DefaultInsertValue
=
"True"
FilterControlAltText
=
"Filter Staff Active column"
CurrentFilterFunction
=
"EqualTo"
CurrentFilterValue
=
"True"
HeaderText
=
"Active"
SortExpression
=
"staffActive"
UniqueName
=
"staffActive"
EditFormColumnIndex
=
"1"
>
</
telerik:GridCheckBoxColumn
>
As you can see I have DefaultInsertValue set to True. However when I go to add a new record the checkbox isn't checked, can anyone think of any reason this may be happening? I should be able to set it to checked in my code but I would like to know what I am doing wrong with this.
6 Answers, 1 is accepted
0
Accepted
Princy
Top achievements
Rank 2
answered on 12 May 2014, 04:59 AM
Hi ,
I have tried your code and it works fine at my end. You can try another approach from code behind as follows:
C#:
Thanks,
Princy
I have tried your code and it works fine at my end. You can try another approach from code behind as follows:
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode && e.Item.OwnerTableView.IsItemInserted)
{
GridEditableItem insertItem = (GridEditableItem)e.Item;
CheckBox chkActive = (CheckBox)insertItem[
"staffActive"
].Controls[0];
chkActive.Checked =
true
;
}
}
Thanks,
Princy
0
DGraham
Top achievements
Rank 1
answered on 12 May 2014, 09:31 AM
With a deadline fast approaching I have given up trying to figure out why my code doesn't appear to work. I guess it is something else on the page but at the moment the solution you posted works fine so I will go with that.
Thanks for your help.
Thanks for your help.
0
Dan
Top achievements
Rank 1
answered on 06 Jan 2015, 07:51 PM
I am having the same issue.
The back end solution does not work for me as I am using the front insert command functionality.
Any other suggestions?
​
The back end solution does not work for me as I am using the front insert command functionality.
Any other suggestions?
​
0
Hi Dan,
Can you please elaborate on what yo mean by "front end insert command functionality"? The idea behind the suggestion provided by Princy is that you need to find the newly created insert item and set the values that you need.
However, setting the DefaultInsertValue should work without any issues.
If you continue to experience problems with this, please elaborate on your exact scenario.
Regards,
Konstantin Dikov
Telerik
Can you please elaborate on what yo mean by "front end insert command functionality"? The idea behind the suggestion provided by Princy is that you need to find the newly created insert item and set the values that you need.
However, setting the DefaultInsertValue should work without any issues.
If you continue to experience problems with this, please elaborate on your exact scenario.
Regards,
Konstantin Dikov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Dan
Top achievements
Rank 1
answered on 08 Feb 2016, 11:07 PM
Hi Konstantin,
Sorry I didn't respond to this back then. I am still having the issue so let me elaborate,
My Grid does not postback when it enters insert mode.
<
MasterTableView
DataSourceID
=
"odsCustContDT"
DataKeyNames
=
"cucID,cusID"
AutoGenerateColumns
=
"False"
CommandItemDisplay
=
"TopAndBottom"
EditMode
=
"Batch"
HorizontalAlign
=
"NotSet"
>
<
BatchEditingSettings
EditType
=
"Row"
/>
0
Hello,
I suggest you go through the following forum thread where a similar problem with batch editing and DefaultInsertValue is disscussed: http://www.telerik.com/forums/set-griddatetimecolumn-default-insert-value-to-today-with-batch-edit-mode
However, as you can see from the public feedback item stated there: http://feedback.telerik.com/Project/108/Feedback/Details/172538-setting-defaultinsertvalue-does-not-work-for-a-batch-editing-grid it is already fixed and if you are using the latest Q1 2016 version of Telerik.UI for ASP.NET AJAX you should not encounter any issues.
Regards,
Pavlina
Telerik
I suggest you go through the following forum thread where a similar problem with batch editing and DefaultInsertValue is disscussed: http://www.telerik.com/forums/set-griddatetimecolumn-default-insert-value-to-today-with-batch-edit-mode
However, as you can see from the public feedback item stated there: http://feedback.telerik.com/Project/108/Feedback/Details/172538-setting-defaultinsertvalue-does-not-work-for-a-batch-editing-grid it is already fixed and if you are using the latest Q1 2016 version of Telerik.UI for ASP.NET AJAX you should not encounter any issues.
Regards,
Pavlina
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items