PDA

View Full Version : [CLOSED] Generate Parameters of loader dynamically



PriceRightHTML5team
Jul 29, 2013, 6:47 AM
I have a container which loads a partial view.
I need to add parameters to it loader dynamically based on the filters seleceted and load the view based on those parameters.
Following is the code:


@(Html.X().Container()
.ID("ViewContainer2")
.Width(900)
.Hidden(true)
.Loader(Html.X().ComponentLoader()
.Url(Url.Action("LoadSnapShotPartialView"))
.Mode(LoadMode.Script)
.Params(new { containerId = "ViewContainer2" })
)
)

In my script i am doing:


var snapShotContainer = Ext.getCmp('ViewContainer2');//.show();
snapShotContainer.loader.paramsFn = getParamForSnapshot();
snapShotContainer.show();

var getParamForSnapshot = function ()
{
var a = { x: "s" };
return a;

}

But its not working. What i am doing wrong?

Daniil
Jul 29, 2013, 6:55 AM
Hi @PriceRightHTML5team,

You should see a JavaScript error like: TypeError: this.paramsFn.call is not a function

You should replace

snapShotContainer.loader.paramsFn = getParamForSnapshot();
with

snapShotContainer.loader.paramsFn = getParamForSnapshot;

PriceRightHTML5team
Jul 29, 2013, 8:10 AM
Thanks Daniil thats working.

But how do i load the container dynamically.Initially its hidden and when i click submit it loads up for the first time.
Next time when i change the filter parameters and click submit it doesn't load with the updated parameters.

Here's what my code looks like:


var btnSubmit_Click = function () {
debugger;
var items = App.CmbTimeBasis.getValue();

if (items == "1") {
var snapShotContainer = Ext.getCmp('ViewContainer2');
snapShotContainer.loader.paramsFn = getParamForSnapshot;
if (snapShotContainer.hidden) {
snapShotContainer.show();
}
else {
snapShotContainer.hide();
snapShotContainer.show();

}
}
}

Daniil
Jul 29, 2013, 12:59 PM
I think you should call the reload method.

snapShotContainer.reload();

Or configure a Loader with:

<Loader TriggerEvent="show" ReloadOnEvent="true" />