Simple: Edit Mode control too small

4 posts, 2 answers
  1. DoomerDGR8
    DoomerDGR8 avatar
    133 posts
    Member since:
    Aug 2010

    Posted 15 Dec 2010 Link to this post

    I have this simple case where I'm using a simple automatic editing functionality of the RadGrid but the only filed that is allowed in edit mode is more like a memo and I need it's height and width expanded. I'm not using any templates here. Kindly see attached screen.

    <asp:Panel runat="server" ID="PanelGrid" Width="630px">
      <fieldset id="fieldGrid" style="width: 608px;">
        <legend>Notes History</legend>
        <telerik:RadGrid ID="RadGridJobs2" runat="server" AutoGenerateColumns="False" AllowPaging="True" GridLines="None"
          Width="608px" Skin="Office2007" SkinID="RadGrid_Paging_Page20_NoExport_Add" AllowAutomaticDeletes="false"
          AllowAutomaticInserts="True" DataSourceID="LinqDataSourceNotes" OnUpdateCommand="RadGridJobs2_UpdateCommand">
          <MasterTableView DataKeyNames="OID" DataSourceID="LinqDataSourceNotes" GridLines="None" CommandItemDisplay="Top">
            <Columns>
              <telerik:GridBoundColumn DataField="NoteDetails" HeaderText="Note" SortExpression="NoteDetails" UniqueName="columnNoteDetails"
                Visible="false" />
              <telerik:GridTemplateColumn UniqueName="columnNewNote" HeaderText="Note History">
                <ItemTemplate>
                  <table cellspacing="0" cellpadding="0" width="100%" border="0" class="TableNoBorders">
                    <tr>
                      <td>
                        <%# "<div><span style='font-weight: bold; '>By </span><span style='font-style: italic; '>" + Eval("User.FirstName") + " " + Eval("User.LastName") + "</span><span style='font-weight: bold; '> on </span><span style='font-style: italic; '>" + Eval("NoteDate", "{0:dd-MMM-yyyy hh:mm tt}") + "</span></div>"%>
                      </td>
                    </tr>
                    <tr>
                      <td>
                        <%# "<div style='font-weight: bold; '>Note: </div>" + Eval("NoteDetails")%>
                      </td>
                    </tr>
                  </table>
                </ItemTemplate>
              </telerik:GridTemplateColumn>
              <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderStyle-Width="10px" ItemStyle-Width="10px" />
              <telerik:GridClientDeleteColumn ButtonType="ImageButton" HeaderStyle-Width="10px" ItemStyle-Width="10px"
                Visible="false" />
            </Columns>
            <CommandItemSettings AddNewRecordText="New Note" />
            <EditFormSettings>
              <EditColumn ButtonType="ImageButton" />
            </EditFormSettings>
          </MasterTableView>
        </telerik:RadGrid>
      </fieldset>
    </asp:Panel>

    protected void RadGridJobs2_UpdateCommand(object source, GridCommandEventArgs e) {
      var editableItem = ((GridEditableItem)e.Item);
      var editNoteID = (long)editableItem.GetDataKeyValue("OID");
     
      //retrieve entity form the Db
      var editNote = DbContext.Notes.Where(nut => nut.OID == editNoteID).FirstOrDefault();
      if (editNote != null) {
        try {
          //update entity's state
          editableItem.UpdateValues(editNote);
     
          //submit changes to Db
          DbContext.SubmitChanges();
     
        } catch (Exception ex) {
     
        }
      }
    }
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 15 Dec 2010 Link to this post

    Hello Hassan,

    You can set the Multiline property to the TextBox as shown below.

    C#:
    protected void RadGridJobs2_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
       {
           if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
           {
               GridEditFormItem editItem = (GridEditFormItem)e.Item;
               TextBox textBox = (TextBox)editItem["columnNoteDetails"].Controls[0];
               textBox.TextMode = TextBoxMode.MultiLine;
           }
       }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. DoomerDGR8
    DoomerDGR8 avatar
    133 posts
    Member since:
    Aug 2010

    Posted 20 Dec 2010 Link to this post

    Excellent. One more thing: If I wanted a RTF or a WYSIWYG editor instead? What will be the required changes then? Do I need to update the SQL Server Datatype for the mapped column too + the HTML and Code behind changes?
  5. Answer
    Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 23 Dec 2010 Link to this post

    Hi Hassan,

    You can try using GridHTMLEditorColumn instead of GridBoundColumn.
    However if you want to use another editor, try placing it in the EditItemTemplate of a GridTemplateColumn.

    All the best,
    Iana
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top