This question is locked. New answers and comments are not allowed.
Hi,
In the grid that I created when I am insert or edit a part I occasionally loose the description field(which is a read only field) when I click the update button or insert button depending upon the scenario. The workflow is as follows for adding a part: I select my part and the description column is filled up but when I hit the insert button the description field looses its text. The same way is for the edit when I hit the update button description field looses the text.
I looked at the javascripts that I wrote when I am updating, saving and databinding the grid by putting a breakpoint in there and everything is fine till I hit this line of code in the javascript:
I am not sure why this line of code removes the description text from the grid column. This thing happens occasionally and not all the time. Is somebody else also facing the same issue?? I am using Telerik Version: 2011.2.712.340. Thanks
In the grid that I created when I am insert or edit a part I occasionally loose the description field(which is a read only field) when I click the update button or insert button depending upon the scenario. The workflow is as follows for adding a part: I select my part and the description column is filled up but when I hit the insert button the description field looses its text. The same way is for the edit when I hit the update button description field looses the text.
<div id="InvoiceLineItemsSection"> <h3>Invoice Items: </h3> @(Html.Telerik().Grid(Model.InvoiceLineItems) .Name("InvoiceLineItems") .DataKeys(keys => keys.Add(i => i.Id)) .Footer(false) .HtmlAttributes(new { style = "width: 1250px" }) .Columns(columns => { columns.Bound(o => o.Part) .Aggregate(aggregrates => aggregrates.Count()) .Width(200); columns.Bound(o => o.Description).Width(200).ReadOnly(); columns.Bound(o => o.Price).Width(200).ReadOnly(); columns.Bound(o => o.Quantity) .Aggregate(aggregates => aggregates.Sum()) .Width(200); columns.Bound(o => o.ExtendedPrice) .Aggregate(aggregates => aggregates.Sum()) .Width(150); columns.Bound(o => o.InvoiceId).Hidden(true); columns.Command(commands => commands.Edit()).Width(200).Title("Command"); }) .ToolBar(commands => commands.Insert()) .DataBinding(databinding => databinding.Ajax() .Select("_SelectInvoiceLineItems", "PPak") .Update("_UpdateInvoiceLineItem", "PPak") .Insert("_InsertInvoiceLineItem", "PPak") ) .ClientEvents(clientEvents => clientEvents.OnSave("onSaveNewLineInvoiceItem") .OnDataBinding("onInvoiceLineItemsDataBinding") .OnEdit("InvoiceLineItemGrid_onEdit") .OnLoad("InvoiceLineItemGrid_onLoad") ) .Filterable() .Sortable() )</div>I looked at the javascripts that I wrote when I am updating, saving and databinding the grid by putting a breakpoint in there and everything is fine till I hit this line of code in the javascript:
(function(i){var c=i.telerik,k=/^\/Date\((.*?)\)\/$/,g=/[0#?]/,l=/[npc?]/;c.scripts.push("telerik.grid.editing.js");var h=function(n){this.formId=n;this._isBuild=false;var p="tUnobtrusiveValidation";var o="tUnobtrusiveContainer";var m=this.unobtrusive={adapters:[],parseElement:function(q,t){var r=i(q),s=r.parents("form")[0],v,u,w;if(!s){return}v=m.validationInfo(s);v.options.rules[q.name]=u={};v.options.messages[q.name]=w={};i.each(this.adapters,function(){var x="data-val-"+this.name,y=r.attr(x),z={};if(y!==undefined){x+="-";i.each(this.params,function(){z[this]=r.attr(x+this)});this.adapt({element:q,form:s,message:y,params:z,rules:u,messages:w})}});if(!t){v.attachValidation()}},parse:function(q){i(q).find(":input[data-val=true]").each(function(){m.parseElement(this,true)});i(q).each(function(){var r=m.validationInfo(this);if(r){r.attachValidation()}})},onError:function(q,t){var s=i(this).find("[data-valmsg-for='"+t[0].name+"']"),r=i.parseJSON(s.attr("data-valmsg-replace"))!==false;s.removeClass("field-validation-valid").addClass("field-validation-error");q.data(o,s);if(r){s.empty();q.removeClass("input-validation-error").appendTo(s)}else{q.hide()}},onErrors:function(q,t){var s=i(this).find("[data-valmsg-summary=true]"),r=s.find("ul");if(r&&r.length&&t.errorList.length){r.empty();s.addClass("validation-summary-errors").removeClass("validation-summary-valid");i.each(t.errorList,function(){i("<li />").html(this.message).appendTo(r)})}},onSuccess:function(q){var s=q.data(o),r=i.parseJSON(s.attr("data-valmsg-replace"));if(s){s.addClass("field-valiion-valid").removeClass("field-validation-error");q.removeData(o);if(r){s.empty()}}},validationInfo:function(q){var s=i(q),r=s.data(p);if(!r){r={options:{errorClass:"input-validation-error",errorElement:"span",errorPlacement:i.proxy(m.onError,q),invalidHandler:i.proxy(m.onErrors,q),messages:{},rules:{},success:i.proxy(m.onSuccess,q)},attachValidation:function(){s.validate(this.options)},validate:function(){s.validate();return s.valid()}};s.data(p,r)}return r}}};h.prototype={build:function(){if(this._isBuild){return}this._isBuild=true;var q=[];function o(t,s,r){t.rules[s]=r;if(t.message){t.messages[s]=t.message}}function p(r){return r.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function n(r){return r.substr(0,r.lastIndexOf(".")+1)}function m(s,r){if(s.indexOf("*.")===0){s=s.replace("*.",r)}return s}q=this.unobtrusive.adapters;q.add=function(t,s,r){if(!r){r=s;s=[]}this.push({name:t,params:s,adapt:r});return this};q.addBool=function(s,r){return this.add(s,function(t){o(t,r||s,true)})};q.addMinMax=function(u,s,w,r,t,v){return this.add(u,[t||"min",v||"max"],function(z){var x=z.params.min,y=z.params.max;if(x&&y){o(z,r,[x,y])}else{if(x){o(z,s,x)}else{if(y){o(z,w,y)}}}})};q.addSingleVal=function(s,t,r){return this.add(s,[t||"val"],function(u){o(u,r||s,u.params[t])})};q.addSingleVal("accept","exts").addSingleVal("regex","pattern");q.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");q.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range");q.add("equalto",["other"],function(s){var r=i(s.form).find(":input[name="+s.params.other+"]")[0];o(s,"equalTo",r)});q.add("required",function(r){if(r.element.tagName.toUpperCase()!=="INPUT"||r.element.type.toUpperCase()!=="CHECKBOX"){o(r,"required",true)}});q.add("remote",["url","type","additionalfields"],function(t){var r={url:t.params.url,type:t.params.type||"GET",data:{}},s=n(t.element.name);i.each(p(t.params.additionalfields||t.element.name),function(u,w){var v=m(w,s);r.data[v]=function(){return i(t.form).find(":input[name='"+v+"']").val()}});o(t,"remote",r)});if(i.validator.unobtrusive&&i.validator.unobtrusive.adapters){i.extend(q,i.validator.unobtrusive.adapters)}i.validator.addMethod("regex",function(r,t,s){if(this.optional(t)){return true}var u=new RegExp(s).exec(r);return u&&u.index==0&&u[0].length==r.length});i.validator.addMethod("number",function(r,u){var s=c.cultureInfo.numericgroupsize;if(s){var t=new c.stringBuilder();t.cat("^-?(?:\\d+|\\d{1,").cat(s).cat("}(?:").cat(c.cultureInfo.numericgroupseparator).cat("\\d{").cat(s).cat("})+)(?:\\").cat(c.cultureInfo.numericdecimalseparator).cat("\\d+)?$");return this.optional(u)||(t&&new RegExp(t.string()).test(r))}return this.optional(u)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(r)})},parse:function(){this.build();this.unobtrusive.parse(this.formId)}};var f=function(m){this.validationMetaData=m};f.prototype={build:function(q){i.validator.addMethod("regex",function(C,E,D){if(this.optional(E)){return true}var F=new RegExp(D).exec(C);return F&&F.index==0&&F[0].length==C.length});i.validator.addMethod("number",function(C,F){var D=c.cultureInfo.numericgroupsize;var E=new c.stringBuilder();E.cat("^-?(?:\\d+|\\d{1,").cat(D).cat("}(?:").cat(c.cultureInfo.numericgroupseparator).cat("\\d{").cat(D).cat("})+)(?:\\").cat(c.cultureInfo.numericdecimalseparator).cat("\\d+)?$");return this.optional(F)... s;if(r==0&&o=="insert"){s="t-grid-edit-cell"}else{if(r==m.columns.length-1){s="t-last"}}return"<td "+(q.attr?q.attr:"")+(s?' class="'+s+'"':"")+">"+q[r==0?o:"display"](p)+"</td>"}).join("")}this.edit=function(o){return n(o,"edit")};this.insert=function(o){return n(o,"insert")};this.display=function(o){return n(o,"display")}};c.grid.DataCellBuilder=function(m){function n(p,o){return i.map(m.columns,function(r,q){return"<td "+(r.attr?r.attr:"")+(q==m.columns.length-1?' class="t-last">':">")+r[o](p)+"</td>"}).join("")}this.edit=function(o){return n(o,"edit")};this.insert=function(o){return n(o,"insert")};this.display=function(o){if(m.rowTemplate){return'<td colspan="'+m.columns.length+'">'+m.rowTemplate(o)+"</td>"}return n(o,"display")}};c.grid.FormContainerBuilder=function(m){function n(o){return'<div class="t-edit-form-container">'+m.html()+m[o]()+"</div>"}this.edit=function(){return n("edit")};this.insert=function(){return n("insert")}};function e(m){return i("<form />",{className:"t-edit-form",id:m}).submit(c.preventDefault)}c.grid.PopUpEditor=function(o){var n;function m(){var q=n.data("tWindow");q&&q.close();n.remove()}function p(r,q){n=i("<div />",{id:o.container.id+"PopUp"}).appendTo(o.container).css({top:0,left:"50%",marginLeft:-90}).tWindow(o.settings).find(".t-window-content").append(o[q](r)).wrapInner(e(o.id)).end();i(o.container).one("dataBound",m);n.find(".t-close").click(c.stopAll(m)).end().data("tWindow").open().title(o[q+"Title"]);return n}this.edit=function(q,r){q.addClass("t-grid-edit-row");return p(r,"edit").data("tr",q)};this.insert=function(q,r){return p(r,"insert")};this.cancel=function(q){q.removeClass("t-grid-edit-row");m()}};c.grid.Editor=function(o){var n=o.groups||function(){return 0};function m(p,q,r){var s=p.find(".t-group-cell,.t-hierarchy-cell");p.addClass("t-grid-edit-row").empty().append(s).append(o[r](q)).closest("table").wrap(function(){if(!i(this).parent().is("form")){return e(o.id)}})}this.cancel=function(p,q){if(p.is(".t-grid-new-row")){p.remove()}else{m(p,q,"cancel");p.removeClass("t-grid-edit-row")}};this.insert=function(r,q){var s='<tr class="t-grid-new-row">'+new Array(n()+1).join('<td class="t-group-cell" />')+((o.details)?'<td class="t-hierarchy-cell"/>':"")+"</tr>";var p=i(s);r.prepend(p);m(p,q,"insert");return p};this.edit=function(p,q){m(p,q,"edit");return p}};c.grid.CellEditor=function(m){this.edit=function(p,o){var n=m.columns[m.cellIndex(p)];if(!n.readonly){p.parent().addClass("t-grid-edit-row").end().empty().html(n.edit(o)).closest("table").wrap(function(){if(!i(this).parent().is("form")){return e(m.id)}});m.bind(p,o);m.validate();p.find(":input:visible:first").trigger("focusin").focus();p.addClass("t-grid-edit-cell")}return !n.readonly};this.display=function(p,o){var n=m.columns[m.cellIndex(p)];p.removeClass("t-grid-edit-cell").empty().html(n.display(o)).parent().removeClass("t-grid-edit-row")}};c.grid.ChangeLog=function(n){this.insert=function(o,q){if(q==undefined){q=o;this.inserted.splice(0,0,q)}else{var p=this.inserted[o];if(p===undefined){this.inserted.splice(0,0,q)}else{i.extend(p,q)}}};this.get=function(p){var o=this.inserted[p];if(this.inserted[p]){return o}return this.updated[p-this.inserted.length]};this.update=function(u,r,q){u=u-this.inserted.length;var v=this.updated[u]||r||{};var t=false;for(var o in q){var s=v[o],p=q[o];if(s instanceof Date){if(p instanceof Date&&p.getTime()!==s.getTime()){t=true}}else{if(p!==s){t=true}}}if(t){this.updated[u]=i.extend({},v,q)}return t};this.erase=function(p,r){var o=this.inserted[p];if(o){this.inserted.splice(p,1)}else{p=p-this.inserted.length;var q=this.updated[p];if(q){delete this.updated[p]}this.deleted[p]=r}};this.clear=function(){this.updated=new Array(n);this.deleted=new Array(n);this.inserted=[]};function m(p,t,v){var w={};for(var u=0,q=0;u<p.length;u++){var s=p[u];if(v(s)){for(var o in s){var r=s[o],x=t+"["+q+"]."+o;if(i.isPlainObject(r)){a(w,r,x)}else{w[x]=r}}q++}}return w}this.serialize=function(o,q,p){return i.extend({},m(o,"inserted",function(){return true}),m(q,"updated",function(r){return r!==undefined}),m(p,"deleted",function(r){return r!==undefined}))};this.dirty=function(){if(this.inserted.length){return true}for(var o=0;o<this.updated.length;o++){if(this.updated[o]){return true}}for(o=0;o<this.deleted.length;o++){if(this.deleted[o]){return true}}return false};this.clear()};c.grid.ErrorView=function(){this.bind=function(m,n){m.find("span[id$=_validationMessage]").removeClass("field-validation-error").addClass("field-validation-valid").html("").end().find(".input-validation-error").removeClass("input-validation-error").addClass("valid");i.each(n,function(q,o){if("errors" in o&&o.errors[0]){var p=q;q=q.replace(".","_");m.find("#"+q+'_validationMessage, [data-valmsg-for="'+p+'"]').html(o.errors[0]).removeClass("field-validation-valid").removeClass("field-valiion-valid").addClass("field-validation-error").end().find("#"+q).removeClass("valid").addClass("input-validation-error")}})}}})(jQuery);