Hi
I'm using a hierarchical grid. In one of them I defined columns but all of them is set to visible = false. All of these columns I binded manualy in nested view template. The grid have just one row. Nested view template is automaticaly expanded. I want to place the edit and the delete button onto view template instead to having them in column (e. g. GridEditCommandColumn). Is this possible ?
I'm using this because I don't want to loose the automatic update delete and insert abilities.
Thank you very much.
Tibor
I'm using a hierarchical grid. In one of them I defined columns but all of them is set to visible = false. All of these columns I binded manualy in nested view template. The grid have just one row. Nested view template is automaticaly expanded. I want to place the edit and the delete button onto view template instead to having them in column (e. g. GridEditCommandColumn). Is this possible ?
I'm using this because I don't want to loose the automatic update delete and insert abilities.
Thank you very much.
Tibor
5 Answers, 1 is accepted
0

Tibor
Top achievements
Rank 1
answered on 15 Nov 2010, 09:52 AM
I just need to have edit and delete button in nested view template and not in column, is this possible ?
0

Princy
Top achievements
Rank 2
answered on 15 Nov 2010, 12:39 PM
Hello Tibor,
I am not quite sure about your requirement. I have tried an almost similar scenario(A grid with NestedViewTemplate). In NestedViewTemplate there is button for Editing and Deleting the grid row. Please take a look at the following code snippet and see if it helps you.
ASPX:
C#:
And the following code snippet shows how to hide the NestedViewItem when grid is in edit mode.
C#:
Thanks,
Princy.
I am not quite sure about your requirement. I have tried an almost similar scenario(A grid with NestedViewTemplate). In NestedViewTemplate there is button for Editing and Deleting the grid row. Please take a look at the following code snippet and see if it helps you.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
AutoGenerateColumns
=
"false"
>
<
MasterTableView
DataKeyNames
=
"EmployeeID"
HierarchyDefaultExpanded
=
"true"
AllowAutomaticDeletes
=
"true"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"EmployeeID"
HeaderText
=
"EmployeeID"
UniqueName
=
"EmployeeID"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"FirstName"
HeaderText
=
"FirstName"
UniqueName
=
"FirstName"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
Text='<%# Bind( "EmployeeID")
%>'></
asp:TextBox
>
<
br
/>
<
asp:TextBox
ID
=
"TextBox2"
runat
=
"server"
Text='<%# Bind( "FirstName")
%>'></
asp:TextBox
>
<
br
/>
<
asp:Button
ID
=
"btnUpdate"
Text
=
"Update"
runat
=
"server"
CommandName
=
"Update"
>
</
asp:Button
>
<
asp:Button
ID
=
"btnCancel"
Text
=
"Cancel"
runat
=
"server"
CommandName
=
"Cancel"
>
</
asp:Button
>
</
FormTemplate
>
</
EditFormSettings
>
<
NestedViewTemplate
>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text='<%# Bind( "EmployeeID")
%>'></
asp:Label
>
<
br
/>
<
asp:Label
ID
=
"Label2"
runat
=
"server"
Text='<%# Bind( "FirstName") %>'></
asp:Label
>
<
br
/>
<
asp:Button
ID
=
"EditButton"
runat
=
"server"
Text
=
"Edit"
OnClick
=
"EditButton_Click"
/>
<
br
/>
<
asp:Button
ID
=
"DeleteButton"
runat
=
"server"
Text
=
"Delete"
OnClick
=
"DeleteButton_Click"
/>
</
NestedViewTemplate
>
</
MasterTableView
>
</
telerik:RadGrid
>
C#:
protected
void
EditButton_Click(
object
sender, EventArgs e)
{
Button btnedit = (Button)sender;
GridNestedViewItem nesteditem = (GridNestedViewItem)btnedit.NamingContainer;
GridTableView parentGrid = (GridTableView)nesteditem.OwnerTableView;
GridDataItem item = (GridDataItem)nesteditem.ParentItem;
item.Edit =
true
;
//make the grid item in edit mode
parentGrid.Rebind();
}
protected
void
DeleteButton_Click(
object
sender, EventArgs e)
{
Button btndelete = (Button)sender;
GridNestedViewItem nesteditem = (GridNestedViewItem)btndelete.NamingContainer;
GridTableView parentGrid = (GridTableView)nesteditem.OwnerTableView;
GridDataItem item = (GridDataItem)nesteditem.ParentItem;
item.FireCommandEvent(
"Delete"
, String.Empty);
// it will fire the command for deleting the grid item
}
And the following code snippet shows how to hide the NestedViewItem when grid is in edit mode.
C#:
protected
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
if
(RadGrid1.EditItems.Count > 0)
{
GridNestedViewItem item = (GridNestedViewItem)RadGrid1.MasterTableView.GetItems(GridItemType.NestedView)[Convert.ToInt32(RadGrid1.EditIndexes[0])];
item.Visible =
false
;
}
}
Thanks,
Princy.
0

Tibor
Top achievements
Rank 1
answered on 15 Nov 2010, 02:39 PM
Yes! Thank you very much, buttons work great.
But another problem arised.
I have a no record template, It no hides on inserting data. It looks realy wrong.
Also expand column is too wide but I don't know if you can help me with that.
But another problem arised.
I have a no record template, It no hides on inserting data. It looks realy wrong.
Also expand column is too wide but I don't know if you can help me with that.
0

Tibor
Top achievements
Rank 1
answered on 03 Jun 2011, 12:03 PM
Is it possible to put confirm on the delete button ?
I tried it on this way:
<asp:Button
ID="DeleteButtonPcorReqsStatements"
runat="server"
Text="Cancella"
OnClientClick="return confirm('Are you sure ?');"
CssClass="infoTableButton infoTableUpdateButton Submit"
nClick="DeleteButtonPcorReqsStatements_Click" />
but after click ok nothing happens (no postback). It seems that the event is canceled or something.
Any idea ?
I tried it on this way:
<asp:Button
ID="DeleteButtonPcorReqsStatements"
runat="server"
Text="Cancella"
OnClientClick="return confirm('Are you sure ?');"
CssClass="infoTableButton infoTableUpdateButton Submit"
nClick="DeleteButtonPcorReqsStatements_Click" />
but after click ok nothing happens (no postback). It seems that the event is canceled or something.
Any idea ?
0

Princy
Top achievements
Rank 2
answered on 03 Jun 2011, 01:19 PM
Hello Tibor,
In order to display a confirmation dialog that prompts the user whether a selected action should be executed (from a button in a template), invoke the confirm javascript method (or use radConfirm for a confirmation dialog that uses skins). If the user chooses the negatve option in the confirmation dialog, return false from the OnClientClick event handler of the button. Check the following help documentation which explains more about this.
Confirmation dialogs.
Thanks,
Princy.
In order to display a confirmation dialog that prompts the user whether a selected action should be executed (from a button in a template), invoke the confirm javascript method (or use radConfirm for a confirmation dialog that uses skins). If the user chooses the negatve option in the confirmation dialog, return false from the OnClientClick event handler of the button. Check the following help documentation which explains more about this.
Confirmation dialogs.
Thanks,
Princy.