Bonjour
J'ai plusieurs tables de données/Entities (ABRICOTS, BANANE) dans le même model que j'ai crée
Comment ça marche: : J'ai une premiere View 'Index' qui affiche une liste déroulante avec deux valeurs "Abricots" et "Banane"et et selon la valeur choisie on affiche le lien ( le chemin) de la table de fruit correspondante et en cliquant sur ce dernier on se redirige vers la view pour l'afficher
Ce que je veux : c'est de faire la pagination pour chaque table ou/et une fonction Search à chaque table que je viens d'afficher
Voila mon model :
Mon controller
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 public class FruitsViewModel { public List<Abricot> abricots { get; set; } public List<Banane> bananes { get; set; } public string Categorie{ get; set; } public string Genre{ get; set; } public string DateExpiration{ get; set; } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public class SaisieReferentielController : Controller { private AntPilOscarEntities db = new AntPilOscarEntities(); private FruitsViewModel axeModel = new FruitsViewModel(); public ActionResult Index() { /*Affiche une liste déroulante pour choisir la table de fruit a afficher*/ return View(); } public ActionResult Index_Abricots() { axeModel.abricots = db.Abricots.ToList(); return View(axeModel); } public ActionResult Index_Bananes() { axeModel.bananes = db.Bananes.ToList(); return View(axeModel); } }
Et j'ai trois views
Index : Affiche en premier lieu une liste déroulante avec deux valeurs "Abricots" et "Banane"et selon la valeur choisie on affiche le lien vers la table de fruit correspondante
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 <Select id="Fruitselector"> <option value="Abricots">Abricots</option> <option value="Banane">Banane</option> </Select> <div id="Abricots" class="axe" style="display: none;"> <h2> @Html.ActionLink("Afficher l'axe choisi", "Index_Abricots") </h2> </div> <div id="Banane" class="axe" style="display: none;"> <h2> @Html.ActionLink("Afficher l'axe choisi", "Index_Banane") </h2> </div> <script type="text/javascript" language="javascript" > $(function () { $('#axeselector').change(function () { $('.axe').hide(); $('#' + $(this).val()).show(); }); }); </script>
et mes deux views
Index_Abricots :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 @model WebPortal.Models.Cubes.Axes.FruitsViewModel <table class="liste" style="width:100%"> <tr> <th style="width:15%;"> Categorie </th> <th style="width:15%"> Genre </th> <th style="width:25%"> DateExpiration </th> </tr> </table> @foreach(var item in Model.abricots) { <table class="liste" style="width:100%"> <tr> <td style="width:15%"> @Html.DisplayFor(modelItem => item.Categorie) </td> <td style="width:15%"> @Html.DisplayFor(modelItem => item.Genre) </td> <td style="width:25%"> @Html.DisplayFor(modelItem => item.DateExpiration) </td> </tr> </table> } <br />
Index_Banane
Merciiiii à tous
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 @model WebPortal.Models.Cubes.Axes.FruitsViewModel <table class="liste" style="width:100%"> <tr> <th style="width:15%;"> Categorie </th> <th style="width:15%"> Genre </th> <th style="width:25%"> DateExpiration </th> </tr> </table> @foreach(var item in Model.banane) { <table class="liste" style="width:100%"> <tr> <td style="width:15%"> @Html.DisplayFor(modelItem => item.Categorie) </td> <td style="width:15%"> @Html.DisplayFor(modelItem => item.Genre) </td> <td style="width:25%"> @Html.DisplayFor(modelItem => item.DateExpiration) </td> </tr> </table> } <br />
Partager