当我在数据表上使用ajax.reload时,它将禁用数据表中的按钮。
为什么?我正在使用它来将新数据重新加载到数据表中。但是它禁用了按钮。为什么会这样呢?如何解决?
create function dbo.CalculateClosestDayOfWeekDate
(
@fromDate DATETIME,
@targetDayOfWeek int -- 1: Monday ... 7: Sunday
)
returns DATETIME
as
begin
-- AdjustedTargetDayOfWeek: ( 7 - @@DATEFIRST + @targetDayOfWeek ) % 7 + 1
-- FromDateDayOfWeek: DATEPART( dw, @fromDate )
-- DayOfWeekDiff = AdjustedTargetDayOfWeek - FromDateDayOfWeek
declare @daysToAdd int
set @daysToAdd = ( ( 7 - @@DATEFIRST + @targetDayOfWeek ) % 7 + 1 ) - DATEPART( dw, @fromDate )
-- if the nearest previous day-of-week is all that's wanted,
-- replace the below block with `if( 0 < @daysToAdd)`
-- and subtract 7 from @daysToAdd if true
if( 3 < ABS( @daysToAdd ) ) -- if magnitude greater than 3
begin
if( 3 < @daysToAdd ) -- if positive, subtract 7
begin
set @daysToAdd = @daysToAdd - 7
end
else -- negative, so add 7
begin
set @daysToAdd = @daysToAdd + 7
end
end
return DATEADD( day, @daysToAdd, @fromDate )
end
go
declare @testData table
(
FromDate dateTime,
TargetDayOfWeek int
)
insert @testData values ( '2018-09-08', 2 ) -- target Tuesday from a Saturday
insert @testData values ( '2018-09-08', 3 ) -- target Wednesday from a Saturday
insert @testData values ( '2018-09-09', 3 ) -- target Wednesday from a Sunday
insert @testData values ( '2018-09-09', 4 ) -- target Thursday from a Sunday
insert @testData values ( '2018-09-10', 4 ) -- target Thursday from a Monday
insert @testData values ( '2018-09-10', 5 ) -- target Friday from a Monday
select
td.FromDate
, td.TargetDayOfWeek
, dbo.CalculateClosestDayOfWeekDate( td.FromDate, td.TargetDayOfWeek ) ResultingDate
from
@testData td