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

Submitting Text area values with double quotes ""

2 Answers 642 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul Grothe
Top achievements
Rank 1
Paul Grothe asked on 09 Dec 2014, 04:30 PM
I have the grid defined below.  I need to be able to edit the Flag Notes column and post it back.  I have so far come up with 2 solutions that are close but don't quite fit the bill.  

#1 gives a textarea to edit in, and it works exactly how it should, except the textarea is always visible and not just when you click in the cell to edit it.  
#2 also works, it hides the text box until you click in it, and it will save the text entered.  The problem comes when double quotes are entered into the field.  then the text that is saved ends with the 'closing' ".  How do I get it to accept both single and double quotes?

#2 is really what we want with the added bonus of actually being able to save double quotes or at least prevent them, maybe replace them with singles

<div id="divSearchResults">
     
       @(Html.Kendo().Grid((IQueryable<CallListModel>)Model)
       .Name("grid")
       .Editable(ed => ed.Mode(GridEditMode.InCell))
       .Pageable()
       .Sortable()
       .Scrollable(a => a.Height("auto"))
       .Filterable()
       .DataSource(ds => ds.Ajax()
           .PageSize(Constants.MaxSearchReults)
           .Sort(sort => sort.Add("Name").Ascending())
           .ServerOperation(false)
           .Update(update => update.Action("SaveFlagComments", "Reports"))
           .Model(mod =>
               {
                   mod.Id(m => m.ID);
                   mod.Field(p => p.Zone).Editable(false);
                   mod.Field(p => p.Name).Editable(false);
                   mod.Field(p => p.CarrierCode).Editable(false);
                   mod.Field(p => p.Location).Editable(false);
                   mod.Field(p => p.DispatchPhone).Editable(false);
                   mod.Field(p => p.DispatchFax).Editable(false);
                   mod.Field(p => p.DispatchEmail).Editable(false);
               }))
       .Columns(columns =>
       {
          columns.Template(@<text></text>)
                   .ClientTemplate("<input type='checkbox' " + ViewBag.disable + 
                   "#= Contacted ? checked='checked':'' # class='chkbx' value='#= ID#' name='selectCarrier' />" +
                   "<input type='hidden' value='#= ID#' name='allCarriers' />")
                   .Width(25);
           columns.Bound(p => p.Zone).Filterable(false).Width(70);
           columns.Bound(p => p.Name).Filterable(false).Width(75);
           columns.Bound(p => p.CarrierCode).Filterable(false).Width(65);
           columns.Bound(p => p.Location).Filterable(false).Width(80);
           columns.Bound(p => p.DispatchPhone).Filterable(false).Width(70);
           columns.Bound(p => p.DispatchFax).Filterable(false).Width(70);
           columns.Bound(p => p.DispatchEmail).Filterable(false).Width(90);
           columns.Template(@<text></text>)
               .ClientTemplate(" <a href='" + Url.Action("Edit", "CarrierView", new { ID = "#=ID#" }) + "', target = '_blank' >Edit</a>").Width(30);
           columns.Bound(p => p.FlagNotes)
 #1              //.ClientTemplate("<textarea name='FlagNotes_#= ID#' cols='60' rows='3' style='height=100px'>#=FlagNotes#</textarea>")
 #2              .ClientTemplate("#=FlagNotes#<input type='hidden' name='FlagNotes_#= ID#' value=\"#=FlagNotes#\">")
               .Filterable(false).Width(120);
          // columns.Command(command => { command.Edit();}).Width(40);
       })
       )

   </div>

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 11 Dec 2014, 01:06 PM
Hello Paul,

Are you submitting the hidden input values? If yes, then you should encode the value set to the input in order to avoid the problem e.g.
.ClientTemplate("#=FlagNotes#<input type='hidden' name='FlagNotes_#= ID#' value=\"#:FlagNotes#\">")


Regards,
Daniel
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Paul Grothe
Top achievements
Rank 1
answered on 11 Dec 2014, 03:24 PM
Thanks, that was what was needed.
Tags
Grid
Asked by
Paul Grothe
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Paul Grothe
Top achievements
Rank 1
Share this question
or