This is a migrated thread and some comments may be shown as answers.

RadGrid DefaultInsertValue issue

6 Answers 218 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DGraham
Top achievements
Rank 1
DGraham asked on 11 May 2014, 10:44 AM
I have the following column in my grid

<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

Sort by
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#:
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.
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?

​
0
Konstantin Dikov
Telerik team
answered on 09 Jan 2015, 08:37 AM
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
 

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
Pavlina
Telerik team
answered on 11 Feb 2016, 02:57 PM
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
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
Tags
Grid
Asked by
DGraham
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
DGraham
Top achievements
Rank 1
Dan
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Pavlina
Telerik team
Share this question
or