2009-09-04 4 views
0

Мне по-прежнему нужна ваша помощь, а точнее реализация сетки ExtJS. Я не могу заставить его работать. У меня есть представление, которое делает поиск с большим количеством параметров, тогда у контроллера будет проведено исследование действий, которое при загрузке страницы я устанавливаю элементы управления последнего, а затем отправляю действие, через которое я выполняю поиск. Это код:Ошибка сетки ExtJs в asp.net mvc

[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 и загрузить страницу, когда я вхожу в отладочный ExtJS сетки, даже если я нажимаю кнопку поиска, чтобы поиск назад мне содержание запроса в формате блокнота и я даже не вхожу в javascript debbugger.

Я могу помочь вам понять, почему, я попробовал это с несколькими примерами extjs, но не работает.

Благодаря

+0

Там нет никого, кто может помочь мне – 2009-09-04 14:38:34

+0

Вероятно потому, что вы должны опубликовать только существенную часть кода , а не целое. – Thevs

ответ

0

сначала вы должны использовать браузер, чтобы убедиться, что ваш asp.net приложение возвращает правильный формат.

Если вы на 100% уверены, что это действительно так, проверьте свой код ExtJs.

Тип общего ответа, но, как сказал Тевс, вы не должны публиковать такой огромный кусок кода.

Также вы могли бы опубликовать xml или json, которые возвращает ваше приложение asp.net, это поможет.

0

Привет всем и спасибо за ваш ответ, я решил проблему, что я передал ему правильные данные из JSon ExtJS

Смежные вопросы