ASP MVC4 jquery 日历
我正在使用 ASP MVC4 jquery 日历。我对此很陌生。我构建了 jquery 日历,以便它突出显示我通过数组传递的特定日期。但现在的问题是,我在数据库中有一个数据表,我将其放入模型中,然后用于根据控制器中的“ID”检索信息并返回到视图。现在我可以以表的形式从数据库获取日期,但我想知道如何将这些特定日期传递到 VIEW 中的 JQUERY CALENDAR 数组。
我还导入了包: 具有核心和日期选择器功能。
但是当我单击下一个箭头或上一个箭头时,它不会显示下个月或上个月。
如果您不明白我的问题,我可以发布代码。请帮助我,因为我已经花了 15 天以上的时间来理解这一点。
I'm working with ASP MVC4 jquery calendar. I'm new to this. I have my jquery calendar built so that it highlights particular dates which i passed through array. But now the question is, I have a table of data in database which I got into Model and then used to it retrieve information based on an 'ID' in controller and returned to VIEW. Now I can get the dates from database in the form of table but I want to know, how I can pass those particular dates to an array of JQUERY CALENDAR in VIEW.
Also I imported package:
with core and datepicker functionalities.
But when i click the next arrow or previous arrow, it doesn't show next or previous months.
I can post the code if you don't understand my question. Please help me since I have already spent more than 15 days understanding this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,这是一个较老的问题,但我自己在日期选择器方面遇到了一些问题,花了我大约 3 个小时的研究时间,直到找到答案......只适合像我这样在寻找答案时最终遇到这个问题的人... *
Jquery UI 已经包含在 .net mvc4 中,datepicker 也包含在捆绑包中。你只需要通过将其添加到你的布局(在头部)中来调用它
,同时确保你的主体底部没有另一个脚本渲染,因为默认情况下它是设置jquery包的地方(至少它是对我来说,在默认项目上),当我使用它时,它会导致日期选择器出现错误。
其中 mydate 是您将在 viewModel 中设置的参数的名称,该参数是 DateTime 对象(或 DateTimeOffSet )(仅当您将日期设置为可为空时, .Value 才是,否则没有必要
)在视图的底部,创建一个 jquery 部分:
(dateformat 和 altformat 是可选的,给它们您想要的值或根本不使用它们)
至于日期数组...我会使用一个 viewmodel,其中包含您的数组为参数,并在视图和控制器之间传递此视图模型。之后定义一个编辑器模板,从那里构建一个包含日期的表格应该非常简单。
well, thats an older question but I had a couple of problem myself with datepicker and took me about 3 hours of research until I found the answer ... this is only for poeple like me who'd end up on this while digging up for answers ... *
Jquery UI is already include in .net mvc4, as is datepicker, its in the bundle. you just have to call it by adding this to your layout ( in the head section )
also, make sure you dont have another script render at the bottom of your body, as its by default where the jquery bundle is set (at least it was for me on the default project ) and it cause a bug with datepicker when I used it.
where mydate is the name of the parameter you'll have set in your viewModel, said parameter is a DateTime object ( or DateTimeOffSet ) (the .Value is only if you set the date as a nullable, its not necessary otherwise)
After on the bottom of your view, create a jquery section :
(dateformat and altformat are optional, give them the value you want or dont use them at all)
as for the array of date ... i'd use a viewmodel, which would contains your array as parameter, and pass this viewmodel between your view and your controller. after that define an Editor template and its should be pretty straighforward to build a table with the dates from there.