Remove CRLF from Grid cell

8 posts, 1 answers
  1. Farhana
    Farhana avatar
    10 posts
    Member since:
    Aug 2013

    Posted 17 Jun 2015 Link to this post

    Hi,

    I have issue while copy pasting a multi-line text with Carriage-return line feed in the GridBoundColumn. I need to remove the CRLF while pasting the text in there. I researched a lot in the forum and So far I have been unsuccessful . Here is my grid looks like as below -

     

    <telerik:RadGrid ID="Grid" runat="server" OnItemDataBound="Grid_ItemDataBound" CssClass ="RadGrid" OnColumnCreated="Grid_ColumnCreated">
       <MasterTableView TableLayout="Fixed" Width="100%" DataKeyNames="StandardItemParaID" ClientDataKeyNames="StandardItemParaID" EditMode="InPlace">
    <CommandItemTemplate>
    <telerik:RadToolBar ID="GridToolBar" runat="server" />
    </CommandItemTemplate>
    <Columns>
    <telerik:GridHyperLinkColumn DataNavigateUrlFields="StandardItemParaID,InspectionTypeID" ImageUrl="~/Icons/GridRowHistory.png" AllowFiltering="false" UniqueName="HistoryLink" ItemStyle-Width="30px" DataNavigateUrlFormatString="javascript:OpenStandardItemParagraphAudit({0},'{1}');" Text="History" AllowSorting="false" />
    <telerik:GridCheckBoxColumn DataField="DataRecordDeleteFlag" ItemStyle-Width="50px" HeaderText="Delete" ></telerik:GridCheckBoxColumn>
    <telerik:GridBoundColumn DataField="StandardItemParaNumber" HeaderText="StandardItem Paragraph No" ItemStyle-Width="92px" MaxLength ="50" />
    <telerik:GridBoundColumn DataField="StandardItemParaDesc" HeaderText="Paragraph Description" ItemStyle-Width="350px" MaxLength ="2000"
    ItemStyle-CssClass="CellWrap"/>
    <telerik:GridDropDownColumn UniqueName="InspectionTypeID" DataField="InspectionTypeID" ListValueField="Key" ListTextField="Description" ItemStyle-Width="160px" SortExpression="InspectionType.InspectionTypeCode" HeaderText="Requirement" DropDownControlType="DropDownList" AllowFiltering="false" AllowSorting="false" />
    <telerik:GridBoundColumn DataField="QANotes" HeaderText="QA Notes" ItemStyle-Width="350px" MaxLength ="500" ItemStyle-CssClass="CellWrap"/>
    </Columns>
    </MasterTableView>
    </telerik:RadGrid>

     

    Problem is in "DataField="StandardItemParaDesc" . I need to paste the following 3 line text there without the CRLF.

    Example Data : Line 1
                              Line 2
                              Line 3

    My expected output should be  Line 1 Line 2 Line 3 after copy paste. Now I am only seeing Line 1. Line 2 and Line 3 are completely missing.

    Please help !!

     

  2. Farhana
    Farhana avatar
    10 posts
    Member since:
    Aug 2013

    Posted 17 Jun 2015 Link to this post

    Here is the Event  handler -

     protected void Grid_ItemDataBound(object sender, GridItemEventArgs e)
    {
         if (e.Item is GridDataItem)
        {

                        item["StandardItemParaDesc"].Text = item["StandardItemParaDesc"].Text.Replace("\r\n", "");
                        item["StandardItemParaDesc"].Wrap = false;
         }

    }

     Its is just not working

  3. Farhana
    Farhana avatar
    10 posts
    Member since:
    Aug 2013

    Posted 18 Jun 2015 Link to this post

    Hi Telerik Admin,

     I would appreciate any response.

     Thanks, Farhana

  4. Eyup
    Admin
    Eyup avatar
    3823 posts

    Posted 22 Jun 2015 Link to this post

    Hi Farhana,

    I suppose you are trying to paste the text when the row is opened in edit mode. I've tried the mentioned behavior on my side and the text is pasted "Line 1 Line 2 Line 3" as expected. Is there something I am missing? Do you observe this behavior on all browsers?

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. Farhana
    Farhana avatar
    10 posts
    Member since:
    Aug 2013

    Posted 22 Jun 2015 in reply to Eyup Link to this post

    Hi Eyup,

    Thank you for your response. Yes I am trying to remove carriage return, line feed in Edit mode. The texts are copied from a PDF dcoument. In my side its not working and Using above code that I post in this thread. I am using both IE and Crome. We are using older Telerik version here - v2014.1.403.40
     Its not working. Could you please paste your code here. May be I am missing some thing.

     Thanks, Farhana

     

  6. Answer
    Eyup
    Admin
    Eyup avatar
    3823 posts

    Posted 25 Jun 2015 Link to this post

    Hello Farhana,

    This issue is not related to Telerik and you will need to search over the net for possible solutions:
    http://brandonpugh.com/blog/2011/10/allow-pasting-multiple-lines-in-ie-textbox/

    For your convenience, I have incorporated the approach suggested above in a RadGrid scenario and prepared a sample runnable web site. Please run the attached application following these steps and let me know if it helps you:
    1. Open Visual Studio
    2. File menu
    3. Open option
    4. Select Web site and target the web site folder.
    5. Include a Bin folder with the Telerik dll assemblies.


    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. Farhana
    Farhana avatar
    10 posts
    Member since:
    Aug 2013

    Posted 26 Jun 2015 in reply to Eyup Link to this post

    Hi Eyup ,

    Thank you so much for providing me towards correct direction. In Chrome it does work without any code changes!. Had no idea that its a browser issue. However I need to make it work for IE and I will try your jQuery snippet  and see if it fixes the issue in IE or not. I will keep posted in this thread.

    Thanks, Farhana

     

  8. Farhana
    Farhana avatar
    10 posts
    Member since:
    Aug 2013

    Posted 26 Jun 2015 in reply to Eyup Link to this post

    Hi Eyup ,

    The JavaScript works for IE !! :)  

    Thanks a bunch !!

Back to Top