How to know the current selected view?

Hi,

I have the unit, week and day view. I also added a filtering feature in my scheduler by resources with submit button “search”. This submit button causes my page to postback. I need this submit button to reload the content of my scheduler. How can I maintain the current selected view after hitting the submit button?

You can get current view by var view = scheduler.getState().mode and select view with scheduler.setCurrentView(null, view)

is there any way I can do it in controller?

In controller you can select view with DHXScheduler.InitialView property, you’ll need to send view name with the other parameters when submitting the page:
client:

var viewName = scheduler.getState().mode; server:

scheduler.InitialView = viewName;

I tried your code :

var viewName = scheduler.getState().mode;

but I’m having the following error:
‘DHTMLX.Scheduler.DHXScheduler’ does not contain a definition for ‘getState’ and no extension method ‘getState’ accepting a first argument of type ‘DHTMLX.Scheduler.DHXScheduler’ could be found (are you missing a using directive or an assembly reference?)

Did I missed something?

scheduler.getState().mode is a client-side method.
In order to maintain selected view after submit, you need to
1)get selected view on the client(with scheduler.getState method),
2)sent it to the server with the other data
3)select this view in the controller with DHXScheduler.InitialView property

In which event of scheduler should I put scheduler.getState().mode?

I already figured it out. Thanks for your help Aliaksandr! :smiley:
I used the event:

     scheduler.attachEvent("onViewChange", function (mode , date){
       //any custom logic here
  });