Hi,
I have a tree list setup as follows:
http://i1135.photobucket.com/albums/m621/surfrat77/TreeListLayout.png
I wish to remove the labels and textbox's as shown below. How do I achieve this?
http://i1135.photobucket.com/albums/m621/surfrat77/EditName.png
http://i1135.photobucket.com/albums/m621/surfrat77/EditValue.png
Thanks
SurfRat
I have a tree list setup as follows:
http://i1135.photobucket.com/albums/m621/surfrat77/TreeListLayout.png
I wish to remove the labels and textbox's as shown below. How do I achieve this?
http://i1135.photobucket.com/albums/m621/surfrat77/EditName.png
http://i1135.photobucket.com/albums/m621/surfrat77/EditValue.png
Thanks
SurfRat
6 Answers, 1 is accepted
0
Surf
Top achievements
Rank 1
answered on 07 Oct 2011, 09:27 AM
Hi,
Can anyone please suggest a solution.
Thanks
SurfRat.
Can anyone please suggest a solution.
Thanks
SurfRat.
0
Hello Surf,
In order to achieve your goal, you can try altering the ReadOnly property of the columns depending on which edit form is open. Or you can define your own FormTemplate and hide the controls in it based on the edited item.
Find the below article for more information on accessing RadTreeList controls:
http://www.telerik.com/help/aspnet-ajax/treelist-accessing-items.html
Give it a try and let me know if any questions or issues arise.
Greetings,
Iana Tsolova
the Telerik team
In order to achieve your goal, you can try altering the ReadOnly property of the columns depending on which edit form is open. Or you can define your own FormTemplate and hide the controls in it based on the edited item.
Find the below article for more information on accessing RadTreeList controls:
http://www.telerik.com/help/aspnet-ajax/treelist-accessing-items.html
Give it a try and let me know if any questions or issues arise.
Greetings,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Surf
Top achievements
Rank 1
answered on 10 Oct 2011, 04:01 PM
Hi Iana,
I tried 'ReadOnly' on the columns but this does not remove the editor row. It only makes it 'ReadOnly'. Even setting the column Visible = False does not remove the editor.
How can I get to the rows that are a part of the editor. I have been able to find the the editor rows in the TreeListEditFormItem but they are not publicly available. See the attached screenshot. If I could delete or make these items Visible = false then I will have achieved my goal.
Thanks
Surf.
I tried 'ReadOnly' on the columns but this does not remove the editor row. It only makes it 'ReadOnly'. Even setting the column Visible = False does not remove the editor.
How can I get to the rows that are a part of the editor. I have been able to find the the editor rows in the TreeListEditFormItem but they are not publicly available. See the attached screenshot. If I could delete or make these items Visible = false then I will have achieved my goal.
Thanks
Surf.
0
Surf
Top achievements
Rank 1
answered on 11 Oct 2011, 11:27 AM
Hi,
Can you please respond to my query. I wish to get this finished as soon as possible. I created a custom editor but this did not help.
Thanks
Surf.
Can you please respond to my query. I wish to get this finished as soon as possible. I created a custom editor but this did not help.
Thanks
Surf.
0
Hi Surf,
The ReadOnly property is working with the last version of RadTreeList for ASP.NET AJAX as shown in this demo. However I prepared a demo for you illustrating how you can set it conditionally.
Kind regards,
Iana Tsolova
the Telerik team
The ReadOnly property is working with the last version of RadTreeList for ASP.NET AJAX as shown in this demo. However I prepared a demo for you illustrating how you can set it conditionally.
Kind regards,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Surf
Top achievements
Rank 1
answered on 13 Oct 2011, 11:23 AM
Hi Iana,
Thanks very much for the help. I have it all working now. To help others who might have the same problem here are some snippets of my code:
.aspx
.cs
Cheers
Surf.
Thanks very much for the help. I have it all working now. To help others who might have the same problem here are some snippets of my code:
.aspx
<
telerik:RadTreeList
ID
=
"m_settingsTreeList"
runat
=
"server"
EnableAJAX
=
"True"
CssClass
=
"contentList"
OnNeedDataSource
=
"OnSettingsTreeListNeedDataSource"
OnItemDataBound
=
"OnSettingsTreeListItemDataBound"
OnCreateColumnEditor
=
"OnSettingsTreeListCreateColumnEditor"
OnUpdateCommand
=
"OnSettingsTreeListUpdateCommand"
OnDeleteCommand
=
"OnSettingsTreeListDeleteCommand"
OnInsertCommand
=
"OnSettingsTreeListInsertCommand"
OnItemCommand
=
"OnSettingsTreeListItemCommand"
AutoGenerateColumns
=
"false"
ParentDataKeyNames
=
"ParentId"
DataKeyNames
=
"Id"
AllowPaging
=
"true"
PageSize
=
"20"
AllowSorting
=
"true"
NoRecordsText
=
"There are no Brand Attributes"
>
<
Columns
>
<
telerik:TreeListBoundColumn
DataField
=
"ParentId"
HeaderText
=
"ParentId"
UniqueName
=
"ParentId"
ReadOnly
=
"true"
Visible
=
"False"
/>
<
telerik:TreeListBoundColumn
DataField
=
"Id"
HeaderText
=
"Id"
UniqueName
=
"Id"
ReadOnly
=
"true"
Visible
=
"False"
/>
<
telerik:TreeListBoundColumn
DataField
=
"Name"
HeaderText
=
"Name"
UniqueName
=
"Name"
/>
<
telerik:TreeListBoundColumn
DataField
=
"BrandAttribute"
HeaderText
=
"Brand Attribute"
UniqueName
=
"BrandAttribute"
/>
<
telerik:TreeListEditCommandColumn
HeaderText
=
""
UniqueName
=
"Edit"
HeaderStyle-Width
=
"80px"
AddRecordText
=
"Add New"
/>
<
telerik:TreeListTemplateColumn
HeaderStyle-Width
=
"50px"
UniqueName
=
"DeleteTemplateColumn"
>
<
ItemTemplate
>
<
asp:LinkButton
ID
=
"m_deleteButton"
runat
=
"server"
CommandName
=
"Delete"
Text
=
"Delete"
OnClientClick
=
"if (!confirm('Are you sure you wish to delete this Brand Attribute?')) return false;"
/>
</
ItemTemplate
>
</
telerik:TreeListTemplateColumn
>
</
Columns
>
<
ClientSettings
>
</
ClientSettings
>
</
telerik:RadTreeList
>
.cs
#region Property SettingsTreeListDataTable
private DataTable m_settingsTreeListDataTable;
/// <
summary
>
///
/// </
summary
>
public DataTable SettingsTreeListDataTable
{
get
{
if (m_settingsTreeListDataTable == null)
{
PropertyType brandPropertyType = PropertyType.GetPropertyType(typeof (Brand));
m_settingsTreeListDataTable = brandPropertyType.GetSettingsAsTreeListDataTable();
}
return m_settingsTreeListDataTable;
}
}
#endregion
protected void OnSettingsTreeListNeedDataSource(object sender, EventArgs e)
{
m_settingsTreeList.DataSource = SettingsTreeListDataTable;
}
protected void OnSettingsTreeListItemDataBound(object sender, TreeListItemDataBoundEventArgs e)
{
if (e.Item is TreeListDataItem)
{
// Hide Add Row button for all.
TreeListDataItem treeListDataItem = (TreeListDataItem) e.Item;
LinkButton addRecordButton = (LinkButton) treeListDataItem["Edit"].Controls[0];
addRecordButton.Visible = false;
if (treeListDataItem.ParentItem != null)
{
// Hide Delete button for child rows.
LinkButton control = (LinkButton) treeListDataItem["DeleteTemplateColumn"].Controls[1];
control.Visible = false;
}
if (treeListDataItem["Name"].Text == "Default")
{
treeListDataItem["Name"].BackColor = Color.LightSkyBlue;
treeListDataItem["BrandAttribute"].BackColor = Color.LightSkyBlue;
}
if (treeListDataItem["BrandAttribute"].Text == "**Default**")
{
treeListDataItem["BrandAttribute"].BackColor = Color.Tomato;
}
}
}
protected void OnSettingsTreeListCreateColumnEditor(object sender, TreeListCreateColumnEditorEventArgs e)
{
TreeListTextBoxColumnEditor editor = e.DefaultEditor as TreeListTextBoxColumnEditor;
if (editor != null)
{
string columnDataField = e.Column.DataField;
if (columnDataField == "Name")
{
SetupNameEditor(editor);
}
else if (columnDataField == "BrandAttribute")
{
SetupBrandAttributeEditor(editor);
}
}
}
private void SetupNameEditor(TreeListTextBoxColumnEditor editor)
{
if (editor.Column.UniqueName == "Name")
{
editor.TextBoxControl.Width = 650;
editor.TextBoxControl.ReadOnly = false;
editor.TextBoxControl.Enabled = true;
}
}
private void SetupBrandAttributeEditor(TreeListTextBoxColumnEditor editor)
{
if (editor.Column.UniqueName == "BrandAttribute")
{
editor.TextBoxControl.Width = 650;
editor.TextBoxControl.ReadOnly = false;
editor.TextBoxControl.Enabled = true;
editor.TextBoxControl.TextMode = TextBoxMode.MultiLine;
editor.TextBoxControl.Rows = 10;
}
}
protected void OnSettingsTreeListDeleteCommand(object sender, TreeListCommandEventArgs e)
{
TreeListDataItem treeListDataItem = e.Item as TreeListDataItem;
TableRow tableRow = e.Item as TableRow;
if (treeListDataItem != null && tableRow != null)
{
string name = tableRow.Cells[3].Text;
PropertyType.GetPropertyType(typeof (Brand)).RemoveSetting(name);
m_settingsTreeList.Rebind();
}
}
protected void OnSettingsTreeListInsertCommand(object sender, TreeListCommandEventArgs e)
{
Hashtable insertedValues = new Hashtable();
TreeListEditableItem newItem = e.Item as TreeListEditableItem;
e.Item.OwnerTreeList.ExtractValuesFromItem(insertedValues, newItem, false);
string settingName = (string) insertedValues["Name"];
if (!string.IsNullOrEmpty(settingName))
{
PropertyType.GetPropertyType(typeof (Brand)).InsertTreeListSetting(settingName);
m_settingsTreeList.Rebind();
}
}
protected void OnSettingsTreeListUpdateCommand(object sender, TreeListCommandEventArgs e)
{
TreeListEditFormItem treeListEditFormItem = (e.Item as TreeListEditFormItem);
if (treeListEditFormItem != null)
{
string id = treeListEditFormItem.ParentItem.GetDataKeyValue("Id").ToString();
DataRow[] settings = SettingsTreeListDataTable.Select(string.Format("Id='{0}'", id));
DataRow setting = null;
if (settings.Length > 0)
{
setting = settings[0];
string name = (string) setting.ItemArray[2];
// Edit the Name.
if (setting.ItemArray[0] == DBNull.Value)
{
TreeListTextBoxColumnEditor nameTreeListTextBoxColumnEditor =
treeListEditFormItem.GetColumnEditor("Name") as TreeListTextBoxColumnEditor;
if (nameTreeListTextBoxColumnEditor != null)
{
string newName = nameTreeListTextBoxColumnEditor.TextBoxControl.Text;
PropertyType.GetPropertyType(typeof (Brand)).UpdateTreeListSetting(newName, name);
}
}
// Edit the BrandAttribute.
else
{
string parentId = (string) setting.ItemArray[0];
DataRow[] parents = SettingsTreeListDataTable.Select(string.Format("Id = '{0}'", parentId));
if (parents.Length > 0)
{
DataRow parent = parents[0];
string parentName = (string) parent.ItemArray[2];
TreeListTextBoxColumnEditor brandAttributeTreeListTextBoxColumnEditor =
treeListEditFormItem.GetColumnEditor("BrandAttribute") as TreeListTextBoxColumnEditor;
if (brandAttributeTreeListTextBoxColumnEditor != null)
{
string newValue = brandAttributeTreeListTextBoxColumnEditor.TextBoxControl.Text;
PropertyType.GetPropertyType(typeof (Brand)).UpdateTreeListSetting(parentName, name,
newValue);
}
}
}
}
m_settingsTreeListDataTable = null;
}
}
protected void OnSettingsTreeListItemCommand(object sender, TreeListCommandEventArgs e)
{
if (e.CommandName == RadTreeList.EditCommandName)
{
m_settingsTreeList.InsertIndexes.Clear();
TreeListDataItem treeListDataItem = e.Item as TreeListDataItem;
if (treeListDataItem != null)
{
if (treeListDataItem.ParentItem == null)
{
HideColumnsForNameEditor();
}
else
{
HideColumnsForBrandAttributeEditor();
}
}
}
if (e.CommandName == RadTreeList.InitInsertCommandName)
{
m_settingsTreeList.InsertIndexes.Clear();
HideColumnsForNameEditor();
}
}
private void HideColumnsForNameEditor()
{
TreeListBoundColumn nameColumn = m_settingsTreeList.GetColumnSafe("Name") as TreeListBoundColumn;
if (nameColumn != null)
{
nameColumn.ReadOnly = false;
}
TreeListBoundColumn brandAttributeBoundColumn = m_settingsTreeList.GetColumnSafe("BrandAttribute") as TreeListBoundColumn;
if (brandAttributeBoundColumn != null)
{
brandAttributeBoundColumn.ReadOnly = true;
}
TreeListTemplateColumn deleteTemplateColumn =
m_settingsTreeList.GetColumnSafe("DeleteTemplateColumn") as TreeListTemplateColumn;
if (deleteTemplateColumn != null)
{
deleteTemplateColumn.ReadOnly = true;
}
}
private void HideColumnsForBrandAttributeEditor()
{
TreeListBoundColumn nameColumn = m_settingsTreeList.GetColumnSafe("Name") as TreeListBoundColumn;
if (nameColumn != null)
{
nameColumn.ReadOnly = true;
}
TreeListBoundColumn brandAttributeBoundColumn = m_settingsTreeList.GetColumnSafe("BrandAttribute") as TreeListBoundColumn;
if (brandAttributeBoundColumn != null)
{
brandAttributeBoundColumn.ReadOnly = false;
}
TreeListTemplateColumn deleteTemplateColumn =
m_settingsTreeList.GetColumnSafe("DeleteTemplateColumn") as TreeListTemplateColumn;
if (deleteTemplateColumn != null)
{
deleteTemplateColumn.ReadOnly = true;
}
}
Cheers
Surf.