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