duanju8308 2010-09-10 23:32
浏览 11

从数据库中断后一个接一个地更新单元格

I have a Excel like online spreadsheet for some purpose and it's almost done and working perfect but there is a issue I am facing and want to rectify.

You can see spreadsheet there at http://partydesigners.site50.net/Excel%20Like%20App/Index.html

The issue is that at one single time more than 1 users are using this spreadsheet and if one person modify any cell the other don't get it updated in their spreadsheet so I planned to have a setTimeout() function to call a function that will update every cell in sheet there from database. '

Now the problem is there are 40 rows each having 10 records from the database and 400 records needs to be updated every "n" seconds so it hangs the browser and UE suffers. I thought I can create a timer like update one cell and then move to another after few seconds and then update another after few seconds in a chain.

You can imagine as I updated first cell and then when it will be finished updating it will call a function for a cell next to it and so on a continue chain.

So what pseudo-jquery code you would write for it?

  • 写回答

1条回答 默认 最新

  • douju1968 2010-09-11 00:24
    关注

    As Jonathun Kuhn mentioned in the comments, it would be better to keep track of only the cells that need to be changed and update them accordingly

    Depending on how you have this setup with your database, will depend on how to keep track of what has been changed. But my first thought is to have a table that keeps track of one change per row along with a timestamp of when the change happened. Then you can run a function from the browser every 'n' seconds that uses some ajax to request all changes since it's last request (can keep track of the unique id of the last update, sort by timestamp and grab everything new).

    This should help speed things up as it will only spend time updating cells that actually need it.

    As a disclaimer, however, it is still very possible that a second user updates a cell before the first edit has shown on their screen. (Think two users editing a cell at virtually the same time, maybe the second initiates a 'save' milliseconds after the first.) The best way I can think of handling this is to show a warning to the second user, if it is noticed that they are editing something very quickly after a previous edit, that they may be overwriting data.

    评论

报告相同问题?

悬赏问题

  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算