2009-09-04 5 views
0

あなたの助けが必要です。具体的には、ExtJSグリッドの実装が必要です。 私はそれを動作させることはできません。 私はより多くのパラメータで検索を行うViewを持っています。コントローラは、ページをロードするときに後者のコントロールを設定し、次に私が検索するアクションを投稿するアクションリサーチを行います。私はメモ帳形式に私に戻って、クエリの内容を検索するための検索ボタンをクリックするにもかかわらず、私はJavaScriptデバッガをテストし、私はデバッグExtJSのグリッドを入力したときにページをロードしているasp.netのExtJsグリッドエラー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) 
] 
)); 

:これはコードです私はdebbuggerのjavascriptに入ることさえしません。

なぜ私はextjのいくつかの例を試してみましたが、うまくいきません。

おかげ

+0

から正しいデータを渡しますが、コードの要部のみを公開しなければならないので、おそらく私 –

+0

を助けることができる誰もがありませんということでした解決、全体ではありません。 – Thevs

答えて

0

まず、あなたのasp.netアプリが適切な形式を返すことを確認するために、ブラウザを使用する必要があります。

あなたが100%確実であることを確認したら、ExtJsコードを確認してください。

一般的な回答の種類はありますが、Thevsのように、このような巨大なコードを投稿するべきではないと指摘しました。

また、xmlやjsonを投稿することができますか?あなたのasp.netアプリケーションはそれが役に立ちそうです。

0

みなさん、こんにちはとお返事のおかげで、私は問題は、私は彼にJSONのExtJSの