This is a migrated thread and some comments may be shown as answers.

Filters defined in View have null values

1 Answer 275 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vesselin Obreshkov
Top achievements
Rank 2
Vesselin Obreshkov asked on 27 Jun 2012, 06:23 PM
When defining filter in my views using the new helpers, the filter values come back null. Here is one example (I have few other very similar grids all producing the exact same result for me).

In this example, I am giving the filter a value coming from the ViewBag.StatusID, however hard-coding a specific value (1) produces the same null value.

View

@(Html.Kendo().Grid<Mobooka.Models.Campaign>()
	.Name("CampaignsGrid")
	.Columns(columns =>
	{
		columns.Bound(o => o.CampaignID).Title("ID").Width(80);
		columns.Bound(o => o.Offer.OfferName).Title("Offer");
		columns.Bound(o => o.Offer.Advertiser.Company.CompanyName).Title("Advertiser").Width(180);
		columns.Bound(o => o.Status.StatusName).Title("Status").Width(100);
	})
	.DataSource(dataSource => dataSource
		.Ajax()
		.Read(read => read.Action("GetCampaigns""Home"))
		.Filter(filter => filter.Add(f => f.StatusID).Equals(ViewBag.StatusID))
.PageSize(25) .ServerOperation(true) ) .Filterable(filtering => filtering .Enabled(true) ) .Pageable(paging => paging .Enabled(true) .Info(true) .PageSizes(false) .Refresh(true) ) .Scrollable(scrolling => scrolling .Enabled(true) .Height(560) .Virtual(true) ) .Sortable(sorting => sorting .Enabled(true) .AllowUnsort(true) .SortMode(GridSortMode.SingleColumn) ) )

Controller

public ActionResult Index()
{
	ViewBag.StatusID = (int)Enumerations.Status.Pending; 
	return View();
}
...
public JsonResult GetCampaigns([DataSourceRequestDataSourceRequest request)
{
	IEnumerable<Campaign> campaigns = db.Campaigns....;
	return new JsonNetResult(campaigns.ToDataSourceResult(request));
}

Request

  1. Request URL:
    http://dashboard.mobooka.local/Admin/Home/GetCampaigns
  2. Request Method:
    POST
  3. Status Code:
    500 Internal Server Error
  4. Request Headersview source
    1. Accept:
      */*
    2. Accept-Charset:
      ISO-8859-1,utf-8;q=0.7,*;q=0.3
    3. Accept-Encoding:
      gzip,deflate,sdch
    4. Accept-Language:
      en-US,en;q=0.8
    5. Cache-Control:
      max-age=0
    6. Connection:
      keep-alive
    7. Content-Length:
      55
    8. Content-Type:
      application/x-www-form-urlencoded
    9. Cookie:
      ASP.NET_SessionId=nrwg2rrgsl1mpskv4yd40na0; .MOBOOKAXAUTH=F8959A12603B131542EB99BCA073D828E64DB8EAA2BF0832D9C12107ED7D453AA9344DEE6AF10ADC966E1C1E50C517378805C2A50D12447FDCEDE5BFB6D69852444068BA6FAE7EFB5B198516494F4223D3221681FF0859D795FDDA70092F184F9C403A49B18BA57BF9F7F248A623F06E40915409CDAA83303B34536978E15A747FA3A47DE6A1D6932845ACDA4461ADC98A05F0EB; MOBOOKASESSION=Name=Mobooka&Type=Employee&A=0&E=7&P=0&U=21; .ASPXROLES=qK_xf5Puh7ahlJTQbCqrdo9FbtqU1d8cQFTVb-CRXFaFk8I1TtnjXrhJMmgwWFii2c24xHu2RAODRoKTCmFc8q0DP9nTavMKWK1XAwbEwtaGeHlg3SHcIjMS8UETV4lu8nOLlc2B6Ke1uUzxKqimbH2WrQN-NvKn212PpnBv6Tw4qeIgGShmK3YMXWjwj_HQzOHx_sjw6fuUOa8RtS-sFZUa6dE-XQyJguHLAlQibYl7DWTCvrSn4Lao7VImcKku9ql_eu6iFVal0kYxnR7e7K5ixOLayyiioUIb7ocwC_xMwPTxc8bAtKe2FTDJbTXSUqrcPu-n4EsffvtjjMgRfQ9ERw7j24hTYPE97fuwO-3YUxYLF5sb9LEM4Flpdf7ppDRelxCJw-1SO84nvQ9pCmX_AfPpdVTGQ1vCrGUkq2TjAD_7Q2c9n9OZhVLlbguEKO52xqcoZ0jOCRtABa8iBv73qBEOcFhd6ju66cV2VJwpPUSzY5dedqxWcQmMS0vKaSPhRALNdJwIJS4IK0w_PsSbU4Tz035EftcE7vb80HJVKS4U0
    10. Host:
      dashboard.mobooka.local
    11. Origin:
      http://dashboard.mobooka.local
    12. Referer:
      http://dashboard.mobooka.local/Admin/Home
    13. User-Agent:
      Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5
    14. X-Requested-With:
      XMLHttpRequest
  5. Form Dataview URL encoded
    1. sort:
    2. page:
      1
    3. pageSize:
      25
    4. group:
    5. filter:
      StatusID~eq~null
  6. Response Headersview source
    1. Cache-Control:
      private
    2. Content-Length:
      8506
    3. Content-Type:
      text/html; charset=utf-8
    4. Date:
      Wed, 27 Jun 2012 17:45:11 GMT
    5. Server:
      Microsoft-IIS/7.5
    6. X-AspNet-Version:
      4.0.30319
    7. X-Powered-By:
      ASP.NET

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 28 Jun 2012, 07:09 AM
Hi Vesselin,

Looking at the code you have pasted it appears that you are calling the Object's Equals method instead the appropriate IsEqualTo. Please modify the code and see if there is a change in the behavior.

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Vesselin Obreshkov
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Share this question
or