问题:
| Coolite 0.8服务器端GridPanel.InsertReocrd方法导致客户端无法识别true 由于在程序中要用到 Guid,js定义guid的重复性相对高一点,所以要在服务器端对gridpanel增加record。 (runat server) Dictionary<string, string> r = new Dictionary<string, string>(13); r.Add("Id", Guid.NewGuid().ToString()); r.Add("IsEntry", "true"); r.Add("UserId", "0"); r.Add("DepartmentId", Guid.NewGuid().ToString()); r.Add("DepartmentSort", Guid.NewGuid().ToString()); r.Add("IsHaveCertificate", "true"); r.Add("Achievement", "0"); r.Add("Remark", "0"); r.Add("SaleCount", "0"); r.Add("AddUserId", "0"); r.Add("AddDate", "0"); r.Add("LastModifyUserId", "0"); r.Add("LastModifyDate", "0"); this.GridPanelDetailSub.InsertRecord(0, r); this.GridPanelDetailSub.RefreshView(); |
由于服务器端的 GridPanel.InsertRecord()的定义如下: public virtual void InsertRecord(int index, IDictionary<string, string> values); 只能插入字符串数据,即使在客户端store的JsonReader.Fields.RecordField 中定义了type="boolean",在赋值后到客户端用 (runat client) 时还是返回字符串的'true',而不是boolean的true,用 record.get('IsEntry')==true 时明明为'true',返回值是false。 |
方法一:
| 目前没找到很好的解决方案,以下方案二选一: 用Ext.Ajax.request到服务器端取新的guid,然后用客户端js代码 (runat client) Ext.getCmp('gridpanel').getStore().insert(0,{field1:true,field2:'asd'}); |
来进行赋值。 |
方法二:
| 只能在判断的时候用 (runat client) if (Boolean(record.get('IsEntry'))==true){} |
这样的方式在客户端判断。 参考: http://www.accdb.net/article.asp?id=1401 不知道定义renderer fn 对解决此问题有没有用,以后再想办法了。 |
上述文章只代表作者的学习经历,并非绝对正确,仅供参考! 本站文章旨在为该问题提供解决思路及关键性代码,并不能完成应该由网友自己完成的所有工作,请网友在仔细看文章并理解思路的基础上举一反三、灵活运用。
access911.net 原创文章,作者本人对文章保留一切权利。 如需转载必须征得作者同意并注明本站链接
|
|