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

see a column in edit mode but not in add mode

9 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Myriam
Top achievements
Rank 1
Myriam asked on 19 Jan 2009, 08:23 PM
Hello
I have a radgrid where I can add and edit.
I would like to see a checkbox column only in edit mode but not in add mode and put the value 0 to the add mode in that field.
Is it possible to do that?
Thanks in advance

9 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 20 Jan 2009, 06:14 AM
Hi Myriam,

One suggestion will be to access the CheckBox from the insert form when the Grid is in the Insert mode and set its display to none. So that when you perform an Insert operation it will insert 0 value for the CheckBox. Here is the code I implemented to hide the CheckBox:

ASPX:
         <telerik:GridCheckBoxColumn UniqueName="CheckCol"  DataField="Discontinued" HeaderText="CheckCol" ></telerik:GridCheckBoxColumn> 


CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridDataInsertItem) && (e.Item.OwnerTableView.IsItemInserted == true)) 
        { 
            GridDataInsertItem insertItem = (GridDataInsertItem)e.Item; 
            CheckBox chkbx = (CheckBox)insertItem["CheckCol"].Controls[0]; 
            chkbx.Style.Add("display","none"); 
        } 
    } 


Regards
Shinu.
0
Myriam
Top achievements
Rank 1
answered on 23 Jan 2009, 02:46 PM

Hello Shinu

First of all, thanks for your answer and your time! And Sorry for my late reply..

I have a question for you, if I have a hierarchical datagrid and the field we are talking about is in the second detail table, do I have to change something in your code as it doesn't enter in the if statement....

Thanks in advance

0
Princy
Top achievements
Rank 1
answered on 23 Jan 2009, 03:43 PM
Hello Myriam,

You can access the checkbox during InsertMode of DetailTable by naking use of the DetailTables name property as shown below:
aspx:
<telerik:RadGrid  ID="RadGrid2" runat="server"  OnItemDataBound="RadGrid2_ItemDataBound" > 
  <MasterTableView Name="Master">       
       <DetailTables  > 
        <telerik:GridTableView DataSourceID="SqlDataSource1" AllowPaging="False" Name="Detail1" runat="server" > 
        <DetailTables> 
          <telerik:GridTableView DataSourceID="SqlDataSource1" CommandItemDisplay="Top" Name="Detail2" EditMode="InPlace" > 
        

cs:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if ((e.Item is GridDataInsertItem) && (e.Item.OwnerTableView.IsItemInserted == true) && (e.Item.OwnerTableView.Name=="Detail2")) 
        { 
            GridDataInsertItem insertItem = (GridDataInsertItem)e.Item; 
            CheckBox chkbx = (CheckBox)insertItem["CheckCol"].Controls[0]; 
            chkbx.Style.Add("display", "none"); 
        }  
   } 

Thanks
Princy.
0
Myriam
Top achievements
Rank 1
answered on 23 Jan 2009, 04:06 PM
Thanks Princy for your quick answer
Unfortunely this doesn't work with 

EditMode

="EditForms"

But it kind of work with InLine EditMode. I say "kind of work" because it shows the column but hide the checkbox. So I see the header of the column. Anyway, I use EditForms mode everywhere so I would really like to have a way to do this with this mode...
Do you have any solution?
Thanks again

 

0
Myriam
Top achievements
Rank 1
answered on 23 Jan 2009, 04:11 PM
Oh and by the way I see that it enter in the ItemDataBound sub as I put a break point.
Thanks
0
Myriam
Top achievements
Rank 1
answered on 27 Jan 2009, 03:11 PM
Hello
ok, Now it enter in the itemDatabound. Here is my code

If

(TypeOf e.Item Is GridEditFormInsertItem) AndAlso (e.Item.OwnerTableView.IsItemInserted = True) AndAlso (e.Item.OwnerTableView.Name = "GTVOffre") Then

 

 

Dim insertItem As GridEditFormInsertItem = DirectCast(e.Item, GridEditFormInsertItem)

 

 

Dim chkbx As CheckBox = DirectCast(insertItem("COURRIEL_ENVOYE").Controls(0), CheckBox)

 

 

chkbx.Style.Add("display", "none")

The problem I got is that it hide the checkbox in insert mode but it shows the label beside...
Does it has a way to hide the checkbox and its label in insert mode?
Thanks again!

 

0
Myriam
Top achievements
Rank 1
answered on 02 Feb 2009, 06:28 PM
any Idea?
0
Accepted
Daniel
Telerik team
answered on 02 Feb 2009, 07:08 PM
Hello Myriam,

Please test the following modification:
insertItem("COURRIEL_ENVOYE").Parent.Visible = False 

I hope this helps.

Kind regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Myriam
Top achievements
Rank 1
answered on 02 Feb 2009, 08:05 PM
Of course it helped!!
That's solved my issue!
Thanks!
Tags
Grid
Asked by
Myriam
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Myriam
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or