Grid上使用callback返回时产生的一些问题

by lkc 2012.5.22 10:15

注:脚本执行有风险,对于客户正式环境请在研发指导下执行。

问题现象:杂发单个性化——通过关联计算,弹性域字段z001*库存数量=成本数量,可正常算出成本数量,但手工修改成本数量保存后,成本数量又恢复到个性化计算出的数量。

经过跟踪发现,修改成本数量时会引发引用开发的callback,这个逻辑返回的js如下

"var ThisGrid = $find('u_M_p0_DataGrid8');ThisGrid.SetReferenceCellValue(0,ThisGrid.GetColumnIndex('SUToCURate'),'2.3333333','2.3333333','2.3333333');;var ThisGrid = $find('u_M_p0_DataGrid8');ThisGrid.SetReferenceCellValue(0,ThisGrid.GetColumnIndex('SUToCURate'),'2.3333333','2.3333333','2.3333333');var ThisGrid = $find('u_M_p0_DataGrid8');ThisGrid.SetReferenceCellValue(0,ThisGrid.GetColumnIndex('CostMny'),'0.000000000','0.000000000','0.000000000');;var ThisGrid = $find('u_M_p0_DataGrid8');ThisGrid.SetReferenceCellValue(0,ThisGrid.GetColumnIndex('SUToCURate'),'2.3333333','2.3333333','2.3333333');var ThisGrid = $find('u_M_p0_DataGrid8');ThisGrid.SetReferenceCellValue(0,ThisGrid.GetColumnIndex('CostMny'),'0.000000000','0.000000000','0.000000000');var ThisGrid = $find('u_M_p0_DataGrid8');ThisGrid.SetReferenceCellValue(0,ThisGrid.GetColumnIndex('StoreUOMQty'),'6','6','6');;;;"

 平台的固有逻辑认为只要是调用参照赋值逻辑,能赋值就一定应该触发事件

代码如下

    SetReferenceCellValue : function(rowIndex,columnIndex,value,code,text,isSynchUpdateValue4P)

    {

        if(this.m_gridFaciesManager!=null)

        {   //设置参照单元值

            //this.get_element().NotEndEdit = true;

            //this.m_gridBodyEventsHandler.CanEndEdit(false);

            //this.get_element().NotEndEdit = false;

 

            this.m_gridFaciesManager.SetReferenceCellValue(rowIndex,columnIndex,value,code,text,isSynchUpdateValue4P);

            /*     delete status change     

           var row =this.D_Body.rows[rowIndex];                

            if(row.Status==RowStatus.Empty)

            {   //设置行位被修改状态           

                row.Status=RowStatus.Added;

            }else if(row.Status==RowStatus.UnChanged)

            {   //设置行位被修改状态           

                row.Status=RowStatus.Modified;

            }       

            */

            var cellData = new CellDataContent("",value); 

            this.OnCellDataValueChanged(cellData,rowIndex,columnIndex);

        }   

    }

 

而本例中列StoreUOMQty实际上是一个数字列 也就是在赋值时应该使用SetCellValue

在该方法中会比较新旧值以判断是否触发事件

 

if(valueString!=oldV){

                      var cellData = new CellDataContent("",valueString); 

                      this._owner.OnCellDataValueChanged(cellData,rowIndex,columnIndex);

            }

小结:如果使用SetReferenceCellValue方法赋值,则每次赋值都会触发值改变事件,不论新旧值是否相等;使用SetCellValue方法赋值,则会比较新旧值,不等时才会触发值改变事件

所以这是应用开发使用方法不当而在个性化中暴露出来的问题

反思:callback的时候可能会修改很多列 也可能产生庞大的脚本来更新界面上grid控件上的值 但是在服务器端多判断一下这个值是不是需要回写(也许现在前端值和model值就是一样

的呢)根据判断结果去掉多余的脚本会不会也有一定的性能优化呢?

 

 留个小疑问:怎么判断产生的js是调用参照赋值还是普通赋值呢?

 

 

 

评论 (18) -

yangy wrote at 2012/5/23 10:03:03 #

顶起~~~~!很好的文章

www.realtown.com 美国 wrote at 2016/3/16 4:20:24 #

First of all I would like to say fantastic blog! I had a quick question in which I'd like to ask if you don't mind. I was curious to know how you center yourself and clear your head before writing. I have had a hard time clearing my mind in getting my thoughts out. I do take pleasure in writing but it just seems like the first 10 to 15 minutes are wasted just trying to figure out how to begin. Any ideas or hints? Appreciate it!

Howtorepairphone.Com 美国 wrote at 2018/6/5 10:26:20 #

You made some good points there. I looked on the web for more info about the issue and found most individuals will go along with your views on this web site.

Acho Tablet Firmwares - CellPhone Firmwares 美国 wrote at 2018/6/10 16:41:55 #

I've been browsing online more than three hours today, yet I never found any interesting article like yours. It's pretty worth enough for me. In my view, if all site owners and bloggers made good content as you did, the web will be a lot more useful than ever before.  Here is my blog;  Acho Tablet Firmwares - CellPhone Firmwares - http://cellphonefirmwares.com/

SM-G357FZ EFS File 美国 wrote at 2018/6/13 15:27:18 #

It's appropriate time to make some plans for the future and it's time to be happy. I've read this post and if I could I want to suggest you some interesting things or advice. Maybe you can write next articles referring to this article. I wish to read more things about it!  Feel free to surf to my web-site ::  SM-G357FZ EFS File - cellphonefirmwares.com/.../

Samsung Galaxy Tab 3V SM-T116NY Firmware 美国 wrote at 2018/6/13 16:18:26 #

It's a pity you don't have a donate button! I'd definitely donate to this brilliant blog! I guess for now i'll settle for book-marking and adding your RSS feed to my Google account. I look forward to brand new updates and will share this website with my Facebook group. Chat soon!  My website -  Samsung Galaxy Tab 3V SM-T116NY Firmware - cellphonefirmwares.com/.../

CellPhone Firmwares 美国 wrote at 2018/6/16 9:05:50 #

Somebody necessarily lend a hand to make seriously articles I'd state. This is the first time I frequented your web page and up to now? I surprised with the analysis you made to make this actual submit extraordinary. Excellent task!  Take a look at my web blog -  CellPhone Firmwares - cellphonefirmwares.com/.../

Samsung Galaxy J710GN ADB Enable File 美国 wrote at 2018/6/22 0:19:09 #

Can I just say what a relief to find a person that actually understands what they are talking about on the internet. You definitely know how to bring a problem to light and make it important. A lot more people should read this and understand this side of the story. I was surprised you aren't more popular since you certainly have the gift.  Also visit my web site ::  Samsung Galaxy J710GN ADB Enable File - cellphonefirmwares.com/.../

Samsung Galaxy J710F ADB Enable File 美国 wrote at 2018/6/22 5:33:09 #

For hottest news you have to pay a quick visit world-wide-web and on web I found this website as a finest web site for newest updates.  My web blog ...  Samsung Galaxy J710F ADB Enable File - cellphonefirmwares.com/.../

mobile phone flash files 美国 wrote at 2018/6/23 6:04:37 #

If some one desires expert view on the topic of blogging and site-building after that i propose him/her to pay a visit this blog, Keep up the good work.  My blog post ...  mobile phone flash files - http://archive.li/A6Jw6

Bypass All Samsung Google Account Lock (FRP) 美国 wrote at 2018/6/28 14:25:50 #

Good day! I could have sworn I've been to this website before but after going through some of the posts I realized it's new to me. Anyhow, I'm certainly happy I found it and I'll be bookmarking it and checking back often!  Here is my web page  Bypass All Samsung Google Account Lock (FRP) - cellphonefirmwares.com/.../

samsung software free download 美国 wrote at 2018/7/1 4:19:01 #

I seriously love your site.. Very nice colors & theme. Did you develop this web site yourself? Please reply back as I'm wanting to create my own blog and would like to know where you got this from or exactly what the theme is called. Thank you!  My weblog;  samsung software free download - sandiego.francephotographers.com/.../

Samsung Galaxy Note 3 Neo LTE SM-N7505 Firmware 美国 wrote at 2018/7/6 3:14:45 #

Aw, this was a very nice post. Taking a few minutes and actual effort to generate a great article… but what can I say… I put things off a lot and don't seem to get anything done.  my webpage ...  Samsung Galaxy Note 3 Neo LTE SM-N7505 Firmware - cellphonefirmwares.com/.../

CellPhone Firmwares 美国 wrote at 2018/7/7 22:27:11 #

Currently it sounds like BlogEngine is the best blogging platform available right now. (from what I've read) Is that what you are using on your blog?  Here is my site -  CellPhone Firmwares - cellphonefirmwares.com/.../

SAMSUNG GALAXY NOTE 9 美国 wrote at 2018/9/18 3:16:20 #

It is a significant service for your closing agents and for your borrowers too since the transaction is not consummated inside lack of these documents. The Apple Mac Decline - The first big hit for Apple in recent memory was the Mac - Book Air. The phone comes having a 5 mega-pixel camera which works on a solution of 2592 by 1944 pixels.

SAMSUNG GALAXY NOTE 9 美国 wrote at 2018/9/20 15:41:21 #

Do not get exited if you notice a mobile phone that's popular in the market understanding that too which has a contemptible price tag. The Apple Mac Decline - The first a nice touch for Apple in recent memory was the Mac - Book Air. The phone comes with a 5 megapixel camera which conditions a resolution of 2592 by 1944 pixels.

samsung galaxy 美国 wrote at 2018/9/21 4:16:29 #

The life expectancy of TV is around decade although some people might sets do not stand to such stretch of time and they fail in giving the top output. If you find the newest Galaxy S2, you will understand what this means.  Therefore, you won't have got symptom in carrying it with your pocket.

via wrote at 2019/8/23 16:39:59 #

Your share is the great knowledge I have gathered, you are an important person I admire, thank you https://happywheels8.com

添加评论



biuquote
微笑得意调皮害羞酷大笑惊讶发呆喜欢可怜尴尬闭嘴噘嘴皱眉伤心抓狂呕吐坏笑漫骂发怒
Loading


RecentComments

评论 RSS

Statistics

989 篇文章
0 个单页
694539 条评论
11 次评分
408949 次访问
访问统计开始于 2019年12月15日
平均日访问 6196 次
当前 114 人在线