0

I am unable to strip HTML inserted by the formatter before inline editing. I am using MVC5 with EF6, so my grid definition is in the GridViewModel.

In my jqGridSelectRow event handler (the View's scripts module), I have the following snippet of code, which never seems to get executed:

grid.jqGrid('editRow',
   true,
   function (rowId) {
      var grid = $("#CreditGrid");
      grid.jqGrid('setCell', rowId, "CreditId", $.jgrid.stripHtml(grid.jqGrid('getCell', rowId, "CreditId")), "", { title: null });
      grid.jqGrid('setCell', rowId, "Reason", $.jgrid.stripHtml(grid.jqGrid('getCell', rowId, "Reason")), "", { title: null });
      grid.jqGrid('setCell', rowId, "Color", $.jgrid.stripHtml(grid.jqGrid('getCell', rowId, "Color")), "", { title: null });
   },
   gridEditSuccess,
   '@Url.Action("DoCRUD", "Credit")',
   lastSel,
   gridAfterSave,
   gridEditError
);

I have no more hair left to tear out, so any help would be appreciated.

Ungaro
  • 522
  • 6
  • 15
  • are you using a custom formatter, you may have to use a custom unformatter? – Sumit Dec 30 '13 at 09:51
  • @Sumit Yes, I am enclosing the value in a inside a custom formatter. I would gladly use a custom unformatter, if I only knew where to trigger it from. There is nothing I can find that would let me access the row or the cell prior to inline editing. Thanks for replying. – Ungaro Dec 30 '13 at 10:44
  • There is an unformat option of the colModel http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter – Sumit Dec 30 '13 at 17:26
  • @Sumit Thanks again for your reply. As I mentioned in the OP, I am using MVC5 and define the grid in my GridViewModel, creating therein each JQGridColumn, which has a property Formatter. Formatter is assigned the name of my Javascript method. JQGridColumn does not have an Unformat property. I do not have a client-side colModel. – Ungaro Dec 31 '13 at 06:10
  • Is this the api you are talking about? http://mvcjquerycontrols.codeplex.com/wikipage?title=API, I know trirand has a product, but I cant find any link beside this one? Anyway, I found a method called setunformatter at the link I provided. – Sumit Dec 31 '13 at 14:13
  • @Sumit Hello again! No, I am using Trirand's jqGrid for ASP.NET MVC as documented here: http://www.trirand.net/documentation/aspnetmvc/index.htm – Ungaro Jan 01 '14 at 00:28
  • I have solved this problem by using custom editors for all fields, stripping the HTML and returning a vanilla control. In retrospect, I should have used Slick.Grid which gives me far better control, even though there is more jQuery code to write. I have about a month of development invested in jqGrid, so I'll toil away with it, albeit unhappily. Very poorly constructed and documented: I lose all formatting when sorting my grid (local data), I pre-validate edits on the client but cannot stop jQuery from making a trip to the server in case of invalid user entry, etc. – Ungaro Jan 01 '14 at 00:35

0 Answers0