문제

나는 검색의 많이 일을 해왔지만, 이것에 대한 명확한 답변을 발견하지 못했습니다.나는 텍스트 박스와 제출 단추와 kendo ui 격자를 설정합니다.그리드의 데이터 소스에 데이터를 게시하여 기준에 따라 결과를 반환합니다.나는 MVC 포장지를 사용하지 않습니다.

편집 : 나는 더 가까이에 없었지만 제출을 클릭 할 때 Post 데이터를 보내려면 DataSource를 가져 오는 것 같습니다.나는 디버깅하고 $ ( "# fmsearch")에서 jQuery 플러그인을 타격하고 양식 데이터를 JSON으로 제대로 변환하는 것으로 확인했지만 업데이트 된 정보를 보내지 않는 것처럼 보입니다.서버가이를 읽을 수 있도록 서버에.

자바 스크립트

var dsGalleryItem = new kendo.data.DataSource({
        transport: {
            read: {
                url: '@Url.Content("~/Intranet/GalleryItem/SearchGalleryItems")',
                type: "POST",
                data: $("#fmSearch").serializeFormToJSON(),
                cache: false
            }
        },
        schema: {
            model: {
                id: "galleryItemID",
                fields: {
                    galleryItemID: {
                        nullable: true
                    },
                    imageName: {},
                    collectionName: {},
                    categoryName: {},
                    lastUpdatedOn: { type: "date" }
                }
            }
        }
    });




    var gvResults = $("#gvResults").kendoGrid({
        autoBind:false,
            columns: [{
                field: "imageName",
                title: "Item Name",
                template: "<a href='@Url.Content("~/Intranet/GalleryItem/Details/")#=galleryItemID#'> #=imageName#</a>"
            }, {
                field: "collectionName",
                title: "Collection"
            }, {
                field: "categoryName",
                title: "Category"
            }, {
                field: "lastUpdatedOn",
                title: "Last Updated",
                format: "{0:M/d/yyyy}"
            }
            ],
            selectable: "row",
            change: onRowSelect,
            dataSource: dsGalleryItem
        });






    $("#fmSearch").submit(
        function (event) {
            event.preventDefault();
            dsGalleryItem.read({ data: $("#fmSearch").serializeFormToJSON() });
    });
.

MVC 액션

[HttpPost]
    public JsonResult SearchGalleryItems(string keyword, int? category, int? collection, DateTime? startDate, DateTime? endDate)
    {

        var galleryItemList = (from g in db.GalleryItems
                               //where g.imageName.Contains(keyword)
                               select new GalleryItemViewModel
                               {
                                   galleryItemID = g.galleryItemID,
                                   imageName = g.imageName,
                                   collectionName = g.collection.collectionName,
                                   categoryName = g.category.categoryName,
                                   lastUpdatedOn = g.lastUpdatedOn
                               });

        var galleryItemCount = Json(galleryItemList.ToList());

        return Json(galleryItemList.ToList()); ;
    }
.

동작은 다른 데이터를 검색하는 데 설치되지 않습니다. 지금은 폼을 그리드에 연결하는 방법을 알아야합니다.

도움이 되었습니까?

해결책

문제가 발견되었습니다.나는 이것을 가지고 있었다 :

dsGalleryItem.read({ data: $("#fmSearch").serializeFormToJSON() });
.

이 필요가 있어야합니다.

dsGalleryItem.read($("#fmSearch").serializeFormToJSON());
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top