我一般不喜欢使用 Excel 和 Microsoft 产品,但 Excel 2007/2010 有一些非常好的条件格式功能,遗憾的是,到目前为止我还没有在许多其他地方看到过这些功能。我在商业报告中广泛使用的其中之一是数据栏。
链接
在我看来,这些数据栏对于理解数字之外的数据含义非常有帮助。虽然 200 名和 2000 名用户之间的差异对于人眼来说只是一个难以理解的数字,但长 10 倍的条形图就直观得多。
我的问题:有没有办法为 jqGrid 中列的每个值包含单元格条件数据栏,从而镜像 Excel 功能?这是我认为摆脱 Excel 工作表并在在线报告系统中实施报告的唯一方法。一旦您习惯了数据栏,它们就是必不可少的,并且它们是我们仍然使用 Excel 制作报告的唯一原因。
如果像我假设的那样,jqGrid 中没有这样的内置功能,您认为定制它会需要很多工作吗?您知道解决这个问题的最佳方法是什么吗?
I generally don't like using Excel and Microsoft products in general, but Excel 2007/2010 has some very nice conditional formatting features which, sadly, I haven't seen in many other places so far. One of these which I use extensively in business reports is data bars.
Link
In my opinion, these data bars are extremely helpful in understanding the meaning of data beyond the numbers. While the difference between 200 and 2000 users is just a hard-to-grasp digit to the human eye, a bar which is 10 times longer is much more intuitive.
My question: Is there any way to include in-cell conditional data bars for every value of a column in jqGrid, mirroring the Excel functionality? This would be the only way I see to get rid of our Excel sheets and implement the reports in an online reporting system. Data bars are simply indispensable once you get used to them, and they are the only reason we still use Excel for reports.
If, as I assume, there is no built-in functionality like this in jqGrid, do you think it would be a lot of work to custom-build it? Do you have any ideas what the best way would be to approach this?
发布评论
评论(2)
这是您在问题中所写的 Excel 的一个有趣功能。我以前不知道这个。
您需要的是实现 自定义格式化程序 函数。总的来说是很容易的。您应该编写一个小函数,根据值(颜色条上的文本)显示单元格包含的内容。此外,您还应该定义取消格式化自定义函数,这将对于你的情况来说很容易。取消格式化函数可以在排序和其他 jqGrid 操作期间使用,其中需要从网格单元获取值。
因此,您的问题可以简化为在颜色条上显示数字。
更新:我一次又一次地思考你的问题,因为我发现使用颜色来格式化数字可能非常有帮助。因此,我花了一些时间创建了相应的代码示例,该示例产生以下结果
并可以实时查看 此处。
对代码的小注释。我必须创建一些 CSS 类,这些类可以在当前的任何浏览器中生成渐变条,但 Opera 除外,其中网格被视为
> CSS 类定义如下:
$(document).ready(function () {/*code*/});
中的 jqGrid 代码:更新:演示的实际版本位于此处。
It is an interesting feature of Excel about which you wrote in your question. I haven't known about this before.
What you need is to implement a custom formater function. In general is is very easy. You should write a small function which display the cell contain based on the value (text over the color bar). Moreover you should define also Unformatting custom function which will be very easy in your case. The unformating function could be used during sorting and other jqGrid operation where one need get the value from the grid cell.
So your problem could be reduced to displaying the number over the color bar.
UPDATED: I though again and again about your question because I find that the usage of colors for formating of numbers could be really helpful. So I spend some time and created the corresponding code example which produce following results
and can be seen live here.
Small comments to the code. I had to create some CSS classes which produce gradient bar in any current browsers excepting Opera where the grid are seen as
The CSS classes are defined as following:
and the jqGrid code inside of
$(document).ready(function () {/*code*/});
:UPDATED: The actualized version of the demo is here.
我认为这是可能的,但需要一些计划和一些假设。
假设:
如果您有一个宽度为 100 像素的数字列,则预先决定拥有 10 种可能的数据栏宽度。 (0、10 像素、20 像素、...100 像素)。其中每一个都可以保存为图像,您也可以拥有漂亮的渐变结束位:)
让我们称它们为 0.png、10.png、20.png、.... 100.png
现在的方法将是这些行:
I think it's possible, but with a little planning and a few assumptions.
Assumptions:
If you have a numeric column with a width of lets say 100px, then make a pre determined decision to have 10 possible data bar widths. (0, 10px, 20px, .... 100px). Each of these can be saved as images, You can have your nice gradient end bit too :)
Lets call them 0.png, 10.png, 20.png, .... 100.png
Now the approach would be something along these lines: