PDA

View Full Version : [CLOSED] [Razor] AjaxProxy pass extra parameter



boris
May 08, 2012, 12:37 PM
Hi, I try to pass parameter to controller method using AjaxProxy in combobox.



...
.Proxy(proxyStoreKlijent =>
{
proxyStoreKlijent.Add(Html.X().AjaxProxy().Url("/Klijent/GetKlijentiZaTipKlijenta")
.Reader(readerKlijent =>
{
readerKlijent.Add(Html.X().JsonReader().IDProperty ("Kl_ID").Root("result"));
})
.ExtraParams(extraParamsKlijent =>
{
Parameter pTipKlijenta = new Parameter { Name = "pTipKlijentaID", Mode = ParameterMode.Value, Value = "Ext.getCmp('ComboBoxTip').getValue()" };
extraParamsKlijent.Add(pTipKlijenta);
})
);
})


But this part of code don't returns value from selected item from another combobox:

Value = "Ext.getCmp('ComboBoxTip').getValue()"

When I try something like this:

Value = "123"
it works and in my controller I get value 123.

How to get selected value from combobox and pass it to controller using extra params in proxy?

Vladimir
May 08, 2012, 12:48 PM
Please use Parameters of store
Store's parameters are deffered (value is retrieved before request), proxy's parameters are just constants (values are retrieved during proxy creation)

boris
May 08, 2012, 1:22 PM
Thanks, it works!

prince-sat
Aug 30, 2012, 7:12 PM
Hi ,
Please Can I get an Example how to use Parametre Store with combobox in this Example

Thinks

Rq : I don'y know how to Post a new Forum Thread

Daniil
Aug 31, 2012, 5:57 AM
Rq : I don'y know how to Post a new Forum Thread

The Help 2.x forum, the green "+ Post New thread" button at the top on the left.

boris
Aug 31, 2012, 8:20 AM
Here is the code. Parameters of store are at the bottom of this code:


Html.X().ComboBox().ID("ComboBoxKlijent").Width(150).LabelWidth(50).ForceSelection(true).E ditable(true).TypeAhead(true).SelectOnFocus(true). Margins("0 0 0 3") //.TypeAheadDelay(2000)
.QueryMode(DataLoadMode.Local).TriggerAction(Trigg erAction.All).ValueField("Kl_ID").DisplayField("Kl_Naziv")
.Store(storeKlijent => {
storeKlijent.Add(Html.X().Store().ID("StoreKlijent").AutoLoad(true)
.Model(modelStoreKlijent => {
modelStoreKlijent.Add(Html.X().Model().ID("ModelKlijent")
.Fields(fieldsModelKlijent => {
fieldsModelKlijent.Add(Html.X().ModelField().Name("Kl_ID").Type(ModelFieldType.Int));
fieldsModelKlijent.Add(Html.X().ModelField().Name("Kl_Naziv"));
})
);
})
.Proxy(proxyStoreKlijent => {
proxyStoreKlijent.Add(Html.X().AjaxProxy().Url("/Klijent/GetKlijentiZaTipKlijenta")
.Reader(readerKlijent => {
readerKlijent.Add(Html.X().JsonReader().IDProperty ("Kl_ID").Root("result"));
})
);
})
.Listeners(listenersStoreKlijent => {
listenersStoreKlijent.Load.Handler = "StoreKlijent_Load();";
})
.Parameters(parametersStoreKlijent => {
parametersStoreKlijent.Add(Html.X().StoreParameter ().Name("pTipKlijentaID").Mode(ParameterMode.Value).Value("Ext.getCmp('ComboBoxTipKlijenta').getValue()"));
})
);
})

prince-sat
Sep 06, 2012, 3:44 PM
Thinks a lot for this example

Can you Please Put the C # Code for this Action " /Klijent/GetKlijentiZaTipKlijenta ".

In Reality I try to Pass a recodID from selected Row in Gridpanel to Refresh another GridPanel like "One To Many " But I have a problem to send the value of RecordID . So if You can Help Me.

Regards

boris
Sep 07, 2012, 8:15 AM
Here is the code. (You don't need all code...)


public AjaxResult GetKlijentiZaTipKlijenta(string pTipKlijentaID)
{
List<Klijent> _Klijent = null;

if (!String.IsNullOrEmpty(pTipKlijentaID))
{
IKlijent ik = new KlijentDAO();
_Klijent = ik.GetKlijentiZaTipKlijenta(Convert.ToInt32(pTipKl ijentaID));
}

var data = from k in _Klijent
where k.Kl_Aktivan == 1
orderby k.Kl_Naziv ascending
select new { k.Kl_ID, k.Kl_Naziv };

AjaxResult result = new AjaxResult { Result = JSON.Serialize(data) };
return result;
}

Second question you must ask somebody else because I don't know :(


I hope this help you.