This is a migrated thread and some comments may be shown as answers.

Remove CRLF from Grid cell

7 Answers 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Farhana
Top achievements
Rank 1
Farhana asked on 17 Jun 2015, 09:56 PM

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 !!

 

7 Answers, 1 is accepted

Sort by
0
Farhana
Top achievements
Rank 1
answered on 17 Jun 2015, 10:00 PM

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

0
Farhana
Top achievements
Rank 1
answered on 18 Jun 2015, 09:31 PM

Hi Telerik Admin,

 I would appreciate any response.

 Thanks, Farhana

0
Eyup
Telerik team
answered on 22 Jun 2015, 07:46 AM
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
0
Farhana
Top achievements
Rank 1
answered on 22 Jun 2015, 03:03 PM

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

 

0
Accepted
Eyup
Telerik team
answered on 25 Jun 2015, 12:13 PM
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
0
Farhana
Top achievements
Rank 1
answered on 26 Jun 2015, 06:14 PM

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

 

0
Farhana
Top achievements
Rank 1
answered on 26 Jun 2015, 08:37 PM

Hi Eyup ,

The JavaScript works for IE !! :)  

Thanks a bunch !!

Tags
Grid
Asked by
Farhana
Top achievements
Rank 1
Answers by
Farhana
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or