🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.pl.comp.lang.csharp
Article #22256

Re: jqGrid i MVC 3

#22256
From: Macko
Date: Tue, 18 Oct 2011 08:18
74 lines
4023 bytes
On 19 Wrz, 10:35, Macko <rychter.mac...@gmail.com> wrote:
> Cze,
>
> więc mam sobie jqGrida posadzonego na stronce:
>
> <script type="text/javascript">
>     $(function () {
>         jQuery("#places").jqGrid({
>             url: '...@Url.Action("GetPlaces", "Trip", new { id =
> @Model.Trip.Id })',
>             datatype: 'json',
>             colNames: ['Id', 'Nazwa', ''],
>             colModel: [
>                     { name: 'id', index: 'id', width: 40, align: 'left' },
>             { name: 'etykieta', index: 'etykieta', width: 440, align:
> 'left' },
>             { name: 'myname', sortable: 'false', edittype: 'select',
> formatter: 'showlink', formatoptions: { baseLinkUrl: 'someurl.php',
> addParam: '&action=edit'} },
>             ],
>             rowNum: 10,
>             rowList: [10, 20, 30],
>             pager: '#pager2',
>             sortname: 'Etykieta',
>             viewrecords: true,
>             sortorder: "desc",
>             loadtext: "Pobieranie danych ...",
>             caption: "JSON Example"
>         });
>         jQuery("#places").jqGrid('navGrid', '#places_pager', { edit:
> false, add: false, del: false });
>     });
> </script>
>
> A więc w urlu do jqGrida jest przekazywany id np. /Trip/GetPlaces/30
>
> i działa sobie fajnie (wyświetla wszystkie atrakcje, czyli wszystkie
> rekordy z tabeli).
> Ja bym chciał żeby działał fajniej tzn wyswietlal atrakcje tylko dla
> podanej podrozy.
> Warstawa danych poprzez NH obsługuje to jednak nie wiem jak teraz
> odczytać w kontrolerze Id podrozy.
>
> Oto metoda w kontrolerze wysyłająca dane do jqGrida:
>
>         public ActionResult GetPlaces(string sidx, string sord, int
> page, int rows)
>         {
>             var searcher = new PlacesSearcher()
>             {
>                 PageNumber = page,
>                 RowsPerPage = rows,
>                 SortOrder = JQueryHelper.OrderToEnum[sord]
>             };
>
>             var places = Repository.Places.GetAll(searcher);
>
>             var result = new
>             {
>                 total = places.TotalPages,
>                 page = places.PageNumber,
>                 records = places.Count,
>                 rows = (from x in places select new { id = x.Id, cell
> = new string[] { x.Id.ToString(), x.Etykieta, "bla" } }).ToArray()
>             };
>
>             return Json(result, JsonRequestBehavior.AllowGet);
>         }
>
> --
> Pozdro,
>  Maćko

Nie ważne, już nie trzeba.
Technical Details
Message-ID: <8484d4bf-ec64-4bb4-b18e-8abaa51a5d76@ff5g2000vbb.googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!goblin3!goblin.stu.neva.ru!news.ripco.com!news.glorb.com!postnews.google.com!ff5g2000vbb.googlegroups.com!not-for-mail
References: <c092b05e-e56c-442a-9dd2-4c4a64ee12f5@f41g2000yqh.googlegroups.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!goblin3!goblin.stu.neva.ru!news.ripco.com!news.glorb.com!postnews.google.com!ff5g2000vbb.googlegroups.com!not-for-mail
From: Macko <rychter.maciej@gmail.com>
Newsgroups: alt.pl.comp.lang.csharp
Subject: Re: jqGrid i MVC 3
Date: Tue, 18 Oct 2011 01:18:33 -0700 (PDT)
Organization: http://groups.google.com
Lines: 85
Message-ID: <8484d4bf-ec64-4bb4-b18e-8abaa51a5d76@ff5g2000vbb.googlegroups.com>
References: <c092b05e-e56c-442a-9dd2-4c4a64ee12f5@f41g2000yqh.googlegroups.com>
NNTP-Posting-Host: 80.94.182.136
Mime-Version: 1.0
X-Trace: posting.google.com 1318925918 27935 127.0.0.1 (18 Oct 2011 08:18:38 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Tue, 18 Oct 2011 08:18:38 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: ff5g2000vbb.googlegroups.com; posting-host=80.94.182.136; posting-account=0LtQXAoAAABsec8yh6dn4H8zU73p878u
User-Agent: G2/1.0
X-Google-Web-Client: true
X-Google-Header-Order: ASELCHRU
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1,gzip(gfe)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit