RadGrid DefaultInsertValue issue

7 posts, 1 answers
  1. DGraham
    DGraham avatar
    31 posts
    Member since:
    Sep 2008

    Posted 11 May 2014 Link to this post

    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.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 May 2014 in reply to DGraham Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. DGraham
    DGraham avatar
    31 posts
    Member since:
    Sep 2008

    Posted 12 May 2014 Link to this post

    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.
  5. Dan
    Dan avatar
    29 posts
    Member since:
    Oct 2013

    Posted 06 Jan 2015 Link to this post

    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?

  6. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 09 Jan 2015 Link to this post

    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.

     
  7. Dan
    Dan avatar
    29 posts
    Member since:
    Oct 2013

    Posted 08 Feb in reply to Konstantin Dikov Link to this post

    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" />

     

     

  8. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 11 Feb Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017