这是一个历史悠久的.我正在编写一个MVC4应用程序,并且刚刚添加了一些代码,用于从控制器传递的JSON对象动态生成一些html.它在SlickGrid事件之后触发,用于双击从控制器获取数据并将一组新的JQ生成的html元素推送到页面的行.
现在为踢球者:
当双击行并看到HTML时,我的显示器(我相信)会发出沉闷的响声.html是一个各种各样的"窗口",因此有一个关闭信息的按钮(除了设置容器显示:none;).
当HTML可见时......听到铃声,当我点击关闭并隐藏HTML时,它会消失.这非常可靠.我不知道是什么原因引起的.这里有一些代码,但我怀疑它会给出任何见解
动态HTML生成功能:
function OrderDataDisplay(obj) {
var tabHTML = "<div id='__t" + obj.DepRunningNo + "' style='position: absolute;" +
"bottom: 0px;" +
"left: 20px;" +
"height: 17px;" +
"text-align: center;" +
"padding: 3px;" +
"width: 100px;" +
"background: -webkit-linear-gradient(top, rgb(20, 20, 20) 0%, rgb(53, 50, 50) 100%);" +
"border-top: 1px;" +
"border-left: 1px;" +
"border-right: 1px;" +
"border-style: ridge;" +
"border-color: #424242;" +
"color: #FFF;" +
"border-radius: 15px 15px 0 0;" +
"font-family: Geneva;" +
"font-size: 15px;'>Ticket #" + …Run Code Online (Sandbox Code Playgroud) 所以我试图用"下雨的绿色代码"创建一个类似矩阵的程序.在我决定将所有字符串实例放入列表并从中绘制/更新之前,一切都进展顺利.为了实现正确的效果,我需要随机化一些事情.
创建所有字符串并将其存储在您在for循环中看到的列表中.间隔和速度随机数会改变字符串下降的速度,以及各个字符在精灵表中旋转的速度.
出于某种原因,虽然我只是让一面文字一下子掉下来,所有的精灵都以同样的速度旋转.这些类及其各自的功能确实有效......所以问题是我的随机数初始化错误是什么?
for (int i = 0; i < (wWidth / 30); i++)
{
Random random = new Random(new System.DateTime().Millisecond);
float randInterval = NextFloat(random);
int dropSpeed = random.Next(1, 7);
_msList.Add(new MatrixString(chinese, randInterval, dropSpeed, dropSpeed, 1.0f, xOff, 10));
xOff = i * 32;
}
Run Code Online (Sandbox Code Playgroud) 我对knockout.js很新,但到目前为止我都喜欢它!我正在写MVC4,并遇到了一些障碍.我用静态数据得到了kojs,但我现在正在使用通过JSON从控制器传递的数据,我不确定如何做到这一点.
最初我的活动有一个"课":
function Activity(context) {
var self = this;
self.type = context.type;
self.name = context.name;
self.time = ko.observable(context.time);
self.product = context.product;
self.item = context.item;
self.itemAmount = context.itemAmount;
self.formattedPrice = ko.computed(function () {
var price = context.netPrice;
return price ? "$" + price.toFixed(2) : "None";
});
}
Run Code Online (Sandbox Code Playgroud)
在我的viewmodel中填充了静态数据:
self.activities = ko.observableArray([
new Activity({ type: 1, name: "John Smith", time: "1 hour", itemAmount: "5", netPrice: 232.16 }),
new Activity({ type: 1, name: "Jane Doe", time: "2 hours", itemAmount: "7", netPrice: 4812.30 }), …Run Code Online (Sandbox Code Playgroud) 我想优化我的LINQ查询.
Orders = (from m in dataContext.SupplierOrdersViews
where (fromDate != toDate ?
m.RecordCreated >= fromDate && m.RecordCreated <= toDate :
(m.RecordCreated.Value.Year == fromDate.Year &&
m.RecordCreated.Value.Month == fromDate.Month &&
m.RecordCreated.Value.Day == fromDate.Day))
select new
{
id = m.ID,
RecordCreated = m.RecordCreated,
RecordDeleted = m.RecordDeleted,
Status = m.Status,
DepRunningNo = m.DepRunningNo,
Name = m.Name,
Address1 = m.Address1,
VehicleRegNo = m.VehicleRegNo,
ProductName = m.ProductName,
Tare = m.Tare < m.Gross ? m.Tare : m.Gross,
Gross = m.Tare < m.Gross ? m.Gross : m.Tare,
NetWeight …Run Code Online (Sandbox Code Playgroud)