Hello, I still need your help, and more specifically the implementation of the ExtJS grid. I can not make it work. I have a View that makes a search with more parameters, then the controller will have the action research that when loading the page I set the controls of the latter, and then I post the action through which I search. This is the code:
[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)
]
));
I have tested a JavaScript debugger and load the page when I enter the debug extjs grid, even though I click the search button to search back to me the contents of the query in notepad format and I do not even enter into debbugger javascript.
I can help you understand why, I tried it with several examples of extjs but does not work.
Thanks