PDA

View Full Version : [CLOSED] ajax proxy/direct



Z
Apr 11, 2022, 4:29 AM
Support,

I am working on a basic example whereas i use ajaxproxy to post via MVC using .net core. Basically, this works great in our ext5 but in ext 7 (core), it doesnt load. I can see the proper call made to the controller, i can see that we return the data via the this.Direct function but the grid never reloads it.

in ext 5, the root properly was "data" and i see forum postings for "results"

Please assist so i can get our basic example working so we can start the real development work using ext7 and .net core6.
thanks
/Z.



cshtml (piece since it is a part page)

<script type="text/javascript">


var storeReadParameters = function (operation) {
return {
apply: {
"par1": 80,
"par2": App.par2.getValue()
}
}
};
</script>

<ext-button
id="test3333"
marginAsString="0 0 0 10"
width="170"
variant="Primary"
text="Find"
onClientClick="App.shiftResults.setVisible(); App.shiftResults.getStore().load();"
iconCls="x-md md-icon-search"
/>

<ext-gridPanel id="shiftResults" title="Results" width="800" height="500" frame="true" margin="10" hidden="true">
<store>
<ext-store autoLoad="false">
<fields>
<ext-dataField name="company" />
<ext-numberDataField name="price" />
<ext-numberDataField name="change" />
<ext-numberDataField name="pctChange" />
<ext-dateDataField name="lastChange" dateFormat="yyyy-MM-dd hh:mm:tt" />
</fields>
<proxy>
<ext-ajaxProxy url="Shift/Test">
<reader>
<ext-jsonReader x-rootProperty="results" />
</reader>
</ext-ajaxProxy>
</proxy>
<customConfig>
<ext-add key="readParameters" value="storeReadParameters" mode="Raw" />
</customConfig>
</ext-store>
</store>
<columns>
<ext-column text="Company" dataIndex="company" flex="1" />
<ext-column text="Price" dataIndex="price" renderer="Ext.util.Format.usMoney" />
<ext-column text="Change" dataIndex="change" renderer="change" />
<ext-column text="Change %" dataIndex="pctChange" renderer="pctChange" />
<ext-dateColumn text="Last Updated" dataIndex="lastChange" width="150" format="yyyy-MM-dd" />
</columns>
</ext-gridPanel>



//controller

using System;

using EasyShift.Models;
using Microsoft.AspNetCore.Mvc;
using Ext.Net.Core;
using System.Collections.Generic;

namespace EasyShift.Controllers
{
public class ShiftController : Controller
{
//not used
public IActionResult Index()
{
return View(new ShiftModel());
}

//using this one
public IActionResult Test(int? par1, int? par2)
{
var now = DateTime.Now.ToString("yyyy-MM-dd hh:mm:tt");

var data = new List<object>
{
new object[] { "3m Co", 71.72, 0.02, 0.03, now },
new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, now },
new object[] { "Exxon Mobil Corp", 68.1, -0.43, -0.64, now },
new object[] { "General Electric Company", 34.14, -0.08, -0.23, now },
new object[] { "General Motors Corporation", 30.27, 1.09, 3.74, now },
new object[] { "Hewlett-Packard Co.", 36.53, -0.03, -0.08, now },
new object[] { "Verizon Communications", 35.57, 0.39, 1.11, now },
new object[] { "Wal-Mart Stores, Inc.", 45.45, 0.73, 1.63, now }
};

return this.Direct(data);
}
}
}

Z
Apr 11, 2022, 4:35 AM
So the x-rootproperty needed to be "result" and not "results"

i solved it myself :)

thanks
/Z

fabricio.murta
Apr 11, 2022, 11:44 PM
It looks like you did it before we could even look it up, glad you figured it out!