首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >asp.net mvc中的ExtJs网格错误

asp.net mvc中的ExtJs网格错误
EN

Stack Overflow用户
提问于 2009-09-04 13:17:26
回答 2查看 1.1K关注 0票数 0

我仍然需要您的帮助,更具体地说,是ExtJS网格的实现。我不能让它工作。我有一个视图,它用更多的参数进行搜索,然后控制器将进行动作研究,当加载页面时,我设置后者的控件,然后我发布我通过其搜索的动作。代码如下:

代码语言:javascript
复制
[Authorize (Roles = "OP_Bollettino")]   
02.         [AcceptVerbs (HttpVerbs.Get)]   
03.         Search public ActionResult ()   
04.         (   
05.  
06.  
07.  
08.             Viewdata [ "checksurname"] = "false";   
09.             abilitatosur.Add ( "Disabled" "Disabled");   
10.             Viewdata [ "abilitasur"] = abilitatosur;   
11.             Viewdata [ "checkcf"] = "false";   
12.             abilitatocf.Add ( "Disabled" "Disabled");   
13.             Viewdata [ "abilitacf"] = abilitatocf;   
14.             abilitatocaus.Add ( "Disabled" "Disabled");   
15.             Viewdata [ "checkcausale"] = "false";   
16.             Viewdata [ "abilitacaus"] = abilitatocaus;   
17.             Viewdata [ "selection"] = "Select";   
18.             string EndDate = null;   
19.             string StartDate = null;   
20.             DataFire DateTime.Now.Date.AddDays = (-30);   
21.             EndDate = dataf.ToShortDateString ();   
22.             data = DateTime.Now.Date;   
23.             StartDate = datai.ToShortDateString ();   
24.             Viewdata [ "StartDate"] = EndDate;   
25.             Viewdata [ "EndDate"] = StartDate;   
26.             Viewdata [ "Cause"] = causale.GetListaCausaleDropDown ();   
27.  
28.  
29.  
30.             return View ( "Search");   
31.  
32.  
33.         )   
34.         / / / <summary>   
35.         / / / Implementation of research, and more precisely when the operator clicking on the button passes the parameters   
36.         / / / Will be used to build the Linq query and return the results in the grid.   
37.         / / / </ Summary>   
38.         / / / <param Name="lastname"> </ param>   
39.         / / / <param Name="causale"> </ param>   
40.         / / / <param Name="datainizio"> </ param>   
41.         / / / <param Name="datafine"> </ param>   
42.         / / / <param Name="cf"> </ param>   
43.         / / / <returns> </ Returns>   
44.         [Authorize (Roles = "OP_Bollettino")]   
45.         [AcceptVerbs (HttpVerbs.Post)]   
46.         [LogError]   
47.         public JsonResult Research (FormCollection formcoll)   
48.         (   
49.  
50.             DateTime date = DateTime.Now.Date.AddDays (-30);   
51.             data.ToShortDateString EndDate = string ();   
52.             data.Date.ToShortDateString ();   
53.             string StartDate = DateTime.Now.Date.ToShortDateString ();   
54.  
55.             date = DateTime.Parse (Request.Form [ "StartDate"]. ToString (). Trim ());   
56.  
57.             DataFire = DateTime.Parse (Request.Form [ "EndDate"]. ToString (). Trim ());   
58.             Viewdata [ "StartDate"] = datai.ToShortDateString ();   
59.             Viewdata [ "EndDate"] = dataf.ToShortDateString ();   
60.             TRY   
61.             (   
62.  
63.  
64.                 var search = utente.GetBollettinoBySearch (null, 0, date, DataFire, null);   
65.  
66.  
67.  
68.  
69.                 if (String.IsNullOrEmpty (Request.Form [ "Surname"]))   
70.                 (   
71.                     Viewdata [ "checksurname"] = true;   
72.                     abilitatosur.Add ( "enabled", "enabled");   
73.                     Viewdata [ "abilitasur"] = abilitatosur;   
74.                     Viewdata [ "cog"] = Request.Form [ "Surname"]. Trim (). ("''", Replace "");   
75.                     name = Request.Form [ "Surname"]. Trim (). ("''", Replace "");   
76.                     utente.GetBollettinoBySearch search = (name, 0, date, DataFire, null);   
77.  
78.                 )   
79.                 else  
80.                 (   
81.                     Viewdata [ "checksurname"] = "false";   
82.                     abilitatosur.Add ( "Disabled" "Disabled");   
83.                     Viewdata [ "abilitasur"] = abilitatosur;   
84.  
85.                 )   
86.  
87.  
88.  
89.                 if (String.IsNullOrEmpty (Request.Form [ "Cause"]))   
90.                 (   
91.  
92.                     Viewdata [ "checkcausale"] = "true";   
93.                     abilitatocaus.Add ( "enabled", "enabled");   
94.                     Viewdata [ "abilitacaus"] = abilitatocaus;   
95.                     Viewdata [ "selection"] = "Select";   
96.                     id_causale string = Request.Form [ "Cause"];   
97.  
98.                     utente.GetBollettinoBySearch search = (null, int.Parse (id_causale), date, DataFire, null);   
99.                     var selectcasuale = causale.GetListaCausaleDropDown (). ToList ();   
100.                     Viewdata [ "Reason"] = new SelectList (selectcasuale.ToList (), "Value", "Text", id_causale), / / new MultiSelectList (causale.GetListaCausaleDropDown (), "Value", "Text", selected);   
101.  
102.                 )   
103.                 else  
104.                 (   
105.                     abilitatocaus.Add ( "Disabled" "Disabled");   
106.                     Viewdata [ "checkcausale"] = "false";   
107.                     Viewdata [ "abilitacaus"] = abilitatocaus;   
108.                     Viewdata [ "selection"] = "Select";   
109.                     var selectcausale = causale.GetListaCausaleDropDown (). ToList ();   
110.                     Viewdata [ "Reason"] = new SelectList (selectcausale.ToList (), "Value", "Text", 0);   
111.                 )   
112.  
113.                 if (String.IsNullOrEmpty (Request.Form [ "codiceF"]))   
114.                 (   
115.                     abilitatocf.Add ( "enabled", "enabled");   
116.                     Viewdata [ "abilitacf"] = abilitatocf;   
117.                     Viewdata [ "checkcf"] = true;   
118.                     Viewdata [ "cf"] = Request.Form [ "codiceF"]. Trim (). ("''", Replace "");   
119.                     cf = Request.Form [ "codiceF"]. Trim (). ("''", Replace "");   
120.                     utente.GetBollettinoBySearch search = (null, 0, date, DataFire, cf); / / res.WithCf (cf);   
121.                 )   
122.                 else  
123.                 (   
124.                     Viewdata [ "checkcf"] = "false";   
125.                     abilitatocf.Add ( "Disabled" "Disabled");   
126.                     Viewdata [ "abilitacf"] = abilitatocf;   
127.  
128.                 )   
129.  
130.  
131.  
132.                 return JSON (datastore = new (search));   
133.  
134.  
135.  
136.             )   
137.  
138.             catch (Exception ex)   
139.             (   
140.                 Utilita.LogError (ex);   
141.  
142.                 return JSON ( "Search");   
143.             )   
144.  
145.  
146.         )  
[Authorize (Roles = "OP_Bollettino")]
         [AcceptVerbs (HttpVerbs.Get)]
         Search public ActionResult ()
         (



             Viewdata [ "checksurname"] = "false";
             abilitatosur.Add ( "Disabled" "Disabled");
             Viewdata [ "abilitasur"] = abilitatosur;
             Viewdata [ "checkcf"] = "false";
             abilitatocf.Add ( "Disabled" "Disabled");
             Viewdata [ "abilitacf"] = abilitatocf;
             abilitatocaus.Add ( "Disabled" "Disabled");
             Viewdata [ "checkcausale"] = "false";
             Viewdata [ "abilitacaus"] = abilitatocaus;
             Viewdata [ "selection"] = "Select";
             string EndDate = null;
             string StartDate = null;
             DataFire DateTime.Now.Date.AddDays = (-30);
             EndDate = dataf.ToShortDateString ();
             data = DateTime.Now.Date;
             StartDate = datai.ToShortDateString ();
             Viewdata [ "StartDate"] = EndDate;
             Viewdata [ "EndDate"] = StartDate;
             Viewdata [ "Cause"] = causale.GetListaCausaleDropDown ();



             return View ( "Search");


         )
         / / / <summary>
         / / / Implementation of research, and more precisely when the operator clicking on the button passes the parameters
         / / / Will be used to build the Linq query and return the results in the grid.
         / / / </ Summary>
         / / / <param Name="lastname"> </ param>
         / / / <param Name="causale"> </ param>
         / / / <param Name="datainizio"> </ param>
         / / / <param Name="datafine"> </ param>
         / / / <param Name="cf"> </ param>
         / / / <returns> </ Returns>
         [Authorize (Roles = "OP_Bollettino")]
         [AcceptVerbs (HttpVerbs.Post)]
         [LogError]
         public JsonResult Research (FormCollection formcoll)
         (

             DateTime date = DateTime.Now.Date.AddDays (-30);
             data.ToShortDateString EndDate = string ();
             data.Date.ToShortDateString ();
             string StartDate = DateTime.Now.Date.ToShortDateString ();

             date = DateTime.Parse (Request.Form [ "StartDate"]. ToString (). Trim ());

             DataFire = DateTime.Parse (Request.Form [ "EndDate"]. ToString (). Trim ());
             Viewdata [ "StartDate"] = datai.ToShortDateString ();
             Viewdata [ "EndDate"] = dataf.ToShortDateString ();
             TRY
             (


                 var search = utente.GetBollettinoBySearch (null, 0, date, DataFire, null);




                 if (String.IsNullOrEmpty (Request.Form [ "Surname"]))
                 (
                     Viewdata [ "checksurname"] = true;
                     abilitatosur.Add ( "enabled", "enabled");
                     Viewdata [ "abilitasur"] = abilitatosur;
                     Viewdata [ "cog"] = Request.Form [ "Surname"]. Trim (). ("''", Replace "");
                     name = Request.Form [ "Surname"]. Trim (). ("''", Replace "");
                     utente.GetBollettinoBySearch search = (name, 0, date, DataFire, null);

                 )
                 else
                 (
                     Viewdata [ "checksurname"] = "false";
                     abilitatosur.Add ( "Disabled" "Disabled");
                     Viewdata [ "abilitasur"] = abilitatosur;

                 )



                 if (String.IsNullOrEmpty (Request.Form [ "Cause"]))
                 (

                     Viewdata [ "checkcausale"] = "true";
                     abilitatocaus.Add ( "enabled", "enabled");
                     Viewdata [ "abilitacaus"] = abilitatocaus;
                     Viewdata [ "selection"] = "Select";
                     id_causale string = Request.Form [ "Cause"];

                     utente.GetBollettinoBySearch search = (null, int.Parse (id_causale), date, DataFire, null);
                     var selectcasuale = causale.GetListaCausaleDropDown (). ToList ();
                     Viewdata [ "Reason"] = new SelectList (selectcasuale.ToList (), "Value", "Text", id_causale), / / new MultiSelectList (causale.GetListaCausaleDropDown (), "Value", "Text", selected);

                 )
                 else
                 (
                     abilitatocaus.Add ( "Disabled" "Disabled");
                     Viewdata [ "checkcausale"] = "false";
                     Viewdata [ "abilitacaus"] = abilitatocaus;
                     Viewdata [ "selection"] = "Select";
                     var selectcausale = causale.GetListaCausaleDropDown (). ToList ();
                     Viewdata [ "Reason"] = new SelectList (selectcausale.ToList (), "Value", "Text", 0);
                 )

                 if (String.IsNullOrEmpty (Request.Form [ "codiceF"]))
                 (
                     abilitatocf.Add ( "enabled", "enabled");
                     Viewdata [ "abilitacf"] = abilitatocf;
                     Viewdata [ "checkcf"] = true;
                     Viewdata [ "cf"] = Request.Form [ "codiceF"]. Trim (). ("''", Replace "");
                     cf = Request.Form [ "codiceF"]. Trim (). ("''", Replace "");
                     utente.GetBollettinoBySearch search = (null, 0, date, DataFire, cf); / / res.WithCf (cf);
                 )
                 else
                 (
                     Viewdata [ "checkcf"] = "false";
                     abilitatocf.Add ( "Disabled" "Disabled");
                     Viewdata [ "abilitacf"] = abilitatocf;

                 )



                 return JSON (datastore = new (search));



             )

             catch (Exception ex)
             (
                 Utilita.LogError (ex);

                 return JSON ( "Search");
             )


         )The code to create the extjs grid is as follows: 

view plaincopy to clipboardprint?
function image (val) (   
     return '<img src="' val'" />';   )     
function url (val) (   
     return '<a href="' val.replace("_t.jpg", ".jpg")'" target="_blank"> Click here to download </ a>';   
)     
var store = new Ext.data.Store ((        url: 'Search',   
     reader: new Ext.data.JsonReader ((   
         root: 'datastore',   
         id: 'UserID'  
    )   
[   
'UserID',   
'Name',   
'Name',   
'Way'  
])   

     baseParams: (   
         query:''  
     )   
));   

var grid = new Ext.grid.GridPanel ((   
     renderTo: 'grid_container',   
     frame: false,   
     border: false,   
     title: 'Search',   
     id: 'grid-search',   
     height: 395,   
     store: store,   
     columns: [   
(Header: "Name", dataIndex: 'Name', width: 120, renderer: image),   
(Header: "Name", dataIndex: 'Name', width: 300, sortable: true),   
(Header: "VIA", dataIndex: 'Via', width: 150, renderer: url)   
]   
));   
function image (val) (
     return '<img src="' val'" />';
)

function url (val) (
     return '<a href="' val.replace("_t.jpg", ".jpg")'" target="_blank"> Click here to download </ a>';
)

var store = new Ext.data.Store ((
     url: 'Search',
     reader: new Ext.data.JsonReader ((
         root: 'datastore',
         id: 'UserID'
     )
[
'UserID',
'Name',
'Name',
'Way'
])

     baseParams: (
         query:''
     )
));

var grid = new Ext.grid.GridPanel ((
     renderTo: 'grid_container',
     frame: false,
     border: false,
     title: 'Search',
     id: 'grid-search',
     height: 395,
     store: store,
     columns: [
(Header: "Name", dataIndex: 'Name', width: 120, renderer: image),
(Header: "Name", dataIndex: 'Name', width: 300, sortable: true),
(Header: "VIA", dataIndex: 'Via', width: 150, renderer: url)
]
)); 

我已经测试了javascript调试器,并在进入debug extjs网格时加载页面,即使我单击搜索按钮以记事本格式向后搜索查询的内容,并且我甚至没有进入debugger JavaScript。

我可以帮助你理解为什么,我尝试了几个extjs的例子,但不起作用。

谢谢

EN

回答 2

Stack Overflow用户

发布于 2009-09-11 01:56:16

首先,您应该使用浏览器来确保您的asp.net应用程序返回正确的格式。

当您百分之百确定它确实如此时,请检查您的ExtJs代码。

一种通用的答案,但就像Thevs指出的那样,你不应该发布如此庞大的代码。

此外,您是否能够发布您的asp.net应用程序返回的xml或json,这将有所帮助。

票数 0
EN

Stack Overflow用户

发布于 2009-09-14 11:09:49

大家好,感谢你的回复,我解决了问题,我给了他来自json extjs的正确数据。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1379193

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档