2013-07-31 58 views
0

您好,我正在使用「Tekerik控件試用版」,我正在構建網格。現在,當我按'編輯'並選擇行ShortDescription時,我想在網格中插入HTML編輯控件。我想要打開HTML控件,以便我可以編輯裏面的所有信息。如何在網格中插入HTML編輯器?

enter image description here

你可以在這裏看到的例子。

這裏是我的代碼

<telerik:RadGrid ID="RadGrid1" runat="server" ShowGroupPanel="True" GridLines="None" DataSourceID="DataSource1" AllowFiltering="False" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowFilteringByColumn="True" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" CellSpacing="0"> 
       <MasterTableView GroupLoadMode="client" ShowGroupFooter="False" GroupsDefaultExpanded="False" AutoGenerateColumns="False" DataKeyNames="ID"> 
        <Columns> 
         <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" FilterControlAltText="Filter ID column" HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID"> 
         </telerik:GridBoundColumn> 
         <telerik:GridCheckBoxColumn DataField="LoadCategory" DataType="System.Boolean" FilterControlAltText="Filter LoadCategory column" HeaderText="LoadCategory" SortExpression="LoadCategory" UniqueName="LoadCategory"> 
         </telerik:GridCheckBoxColumn> 
         <telerik:GridBoundColumn DataField="ProductCategory" FilterControlAltText="Filter ProductCategory column" HeaderText="ProductCategory" SortExpression="ProductCategory" UniqueName="ProductCategory"> 
         </telerik:GridBoundColumn> 
         <telerik:GridBoundColumn DataField="ShortDescription" FilterControlAltText="Filter ShortDescription column" HeaderText="ShortDescription" SortExpression="ShortDescription" UniqueName="ShortDescription"> 

          <%-- This is the row --%> 
         </telerik:GridBoundColumn> 
         <telerik:GridBoundColumn DataField="NumberOfItems" DataType="System.Int16" FilterControlAltText="Filter NumberOfItems column" HeaderText="NumberOfItems" SortExpression="NumberOfItems" UniqueName="NumberOfItems"> 
         </telerik:GridBoundColumn> 
         <telerik:GridBoundColumn DataField="CategoryTitle" FilterControlAltText="Filter CategoryTitle column" HeaderText="CategoryTitle" SortExpression="CategoryTitle" UniqueName="CategoryTitle"> 
         </telerik:GridBoundColumn> 
         <telerik:GridBoundColumn DataField="SeoTitle" FilterControlAltText="Filter SeoTitle column" HeaderText="SeoTitle" SortExpression="SeoTitle" UniqueName="SeoTitle"> 
         </telerik:GridBoundColumn> 
         <telerik:GridBoundColumn DataField="SeoDescription" FilterControlAltText="Filter SeoDescription column" HeaderText="SeoDescription" SortExpression="SeoDescription" UniqueName="SeoDescription"> 
         </telerik:GridBoundColumn> 
        </Columns> 
       </MasterTableView> 
       <ClientSettings AllowDragToGroup="True"> 
       </ClientSettings> 
      </telerik:RadGrid> 

任何想法如何,我可以做到這一點?

回答

0

我覺得你只需要改變溶液

<telerik:GridBoundColumn DataField="ShortDescription" FilterControlAltText="Filter ShortDescription column" HeaderText="ShortDescription" SortExpression="ShortDescription" UniqueName="ShortDescription"> 
         </telerik:GridBoundColumn> 

GridHTMLEditorColumn

<telerik:GridHTMLEditorColumn DataField="ShortDescription" FilterControlAltText="Filter ShortDescription column" HeaderText="ShortDescription" SortExpression="ShortDescription" UniqueName="ShortDescription"> 
         </telerik:GridHTMLEditorColumn> 
1

使用UserControlEditForm

<EditFormSettings UserControlName="yourUserControl.ascx" EditFormType="WebUserControl"> 
      <EditColumn FilterControlAltText="Filter EditCommandColumn column"> 
      </EditColumn> 
    </EditFormSettings> 

yourUserControl.ascx,您可以添加Telerik的RadEditor或其他一些HTML編輯器。

這是如何從電網到用戶控件中獲得價值,

object _fieldValue = DataBinder.Eval(DataItem, "YourDataField"); 
     if ((_fieldValue != DBNull.Value) && (_fieldValue != null)) 
     { 
      yourHtmlEditor.Text = _fieldValue .ToString(); 

     } 

,這是如何從用戶控件獲得價值到您的主電網,

UserControl usercontrol = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); 
    string _value= (usercontrol.FindControl("yourHtmlEditor") as typeOfyourEditor).Text; 

你可以看到reference1reference2

不使用userControlEditForm,您可以使用editFormTemplate

<EditFormSettings EditFormType="Template"> 
      <FormTemplate> 

demo1demo2

好運:)

+0

THX @zey但不正是我需要的,但THX任何方式 –