PDA

View Full Version : Populating SelectField using JsonReader errors with Uncaught SyntaxError: Unexpected token



cynsystems
Oct 12, 2017, 5:41 PM
I am running Ext.Net.Mobile.MVC 4.10

I am trying to fill a SelectField's store. I am successful using a List generated and passed as part of the ViewModel and creating a separate store that uses an AjaxProxy to fill the store. But when I try to integrate this into the SelectField - the page does not load and I can see the error "Uncaught SyntaxError: Unexpected token < ext.mobile.axd:2

I copy over the same code to a Ext.NET 4.4.1 project
replace ComboBox for SelectField and FieldLabel for Label and the load works...

On the example the offending code is commented out.
Thanking the community in advance!!!
Cyndi Pruett


using System;using System.Collections.Generic;using System.ComponentModel;
using System.Linq;using System.Reflection;using System.Text;using System.Text.RegularExpressions;using System.Web;using System.Web.Caching;using System.Web.Mvc;
using Ext.Net;using Ext.Net.Mobile;using Ext.Net.Mobile.MVC;using Ext.Net.Utilities;
namespace versa_tracker.Mobile.Controllers{ public class TestController : Controller { protected override void Dispose(bool disposing) { base.Dispose(disposing); } public new ActionResult View() { ViewModel_Test vm = new ViewModel_Test(); vm.Date_Options = Setup_Date_Options_ValueText().ToList(); string ViewName = "View"; return View(ViewName,vm); } public ActionResult Return_Date_Options() { var records = Setup_Date_Options_ValueText(); return this.Store(records, records.Count()); } public IEnumerable<ValueText> Setup_Date_Options_ValueText() { List<ValueText> records = new List<ValueText>{ new ValueText {Value= "LT" ,Text= "Before" }, new ValueText {Value= "GT" ,Text= "After"}, new ValueText {Value= "EQ" ,Text= "On"} }.ToList(); return records; } } public class ValueText { public string Value { get; set; } public string Text { get; set; } } public class ViewModel_Test { public List<ValueText> Date_Options { get; set; } }}


@using Ext.Net.Mobile;@using Ext.Net.Mobile.MVC;@using versa_tracker.Mobile.Controllers;
@model versa_tracker.Mobile.Controllers.ViewModel_Test
@{ Layout = null;}

<!DOCTYPE html>
<html><head> <title>Ext.NET Mobile MVC</title> </head>
@(Html.X().Store().ID("Store_Date_Options_1") .DataSource(Model.Date_Options as IEnumerable<ValueText>) .Model(Html.X().Model().IDProperty("Value") .Fields(new ModelField("Value"), new ModelField("Text") ) )
)
@(Html.X().Store().ID("Store_Date_Options_2").RemoteSort(false).AutoLoad(true) .Proxy(Html.X().AjaxProxy().Url(Url.Action("Return_Date_Options")) .ActionMethods(actions => { actions.Read = HttpMethod.POST; }).Reader(Html.X().JsonReader().RootProperty("data"))) .Model(Html.X().Model().IDProperty("Value") .Fields(Html.X().ModelField().Name("Value").Type(ModelFieldType.String), Html.X().ModelField().Name("Text").Type(ModelFieldType.String) ) //end of fields ) // end of model)

<body> @Html.X().ResourceManager() @(Html.X().Viewport() .Layout(LayoutType.VBox) .Padding(10) .Items( Html.X().SelectField().Label("PreLoad").ID("filter_DateOptions_1").Width(400) .DisplayField("Text").ValueField("Value").AutoSelect(false) .StoreID("Store_Date_Options_1"),
Html.X().SelectField().Label("Store-Load").ID("filter_DateOptions_2").Width(400) .DisplayField("Text").ValueField("Value").AutoSelect(false) .StoreID("Store_Date_Options_2") //, //Html.X().SelectField().Label("Self Load").ID("filter_DateOptions_3").Width(400) // .DisplayField("Text").ValueField("Value").AutoSelect(false) // .Store(Html.X().Store().ID("Store_Date_Options_ListItems_3").AutoLoad(true) // .Proxy(Html.X().AjaxProxy().Url(Url.Action("Return_Date_Options")) // .ActionMethods(actions => { actions.Read = HttpMethod.POST; }).Reader(Html.X().JsonReader().RootProperty("data"))) // .Model(Html.X().Model().IDProperty("Value") // .Fields(Html.X().ModelField().Name("Value").Type(ModelFieldType.String), // Html.X().ModelField().Name("Text").Type(ModelFieldType.String) // ) //end of fields // ) // end of model // )//end of store ) // end of items )
</body></html>