[CLOSED] Change the Checkbox selection model (MVC Razor)

  1. #1

    [CLOSED] Change the Checkbox selection model (MVC Razor)

    Hi guys,
    I have a gridpanel which is created using a checkbox selection model in "MULTI" mode and CheckOnly. I'm trying to change the gridpanel checkbox selection model from a controller action to make it "SINGLE" and full row select. The grid is bound by ID to a Store which is loaded via AjaxProxy from an Api controller. So far I have tried .....

    
                var gp = X.GetCmp<GridPanel>("PERFORMANCE_CRITERIA_GRID_PANEL_ID");
                gp.SelectionModel.Clear();
                CheckboxSelectionModel csm = new CheckboxSelectionModel();
                csm.Mode = SelectionMode.Single;
                csm.CheckOnly = false;
                csm.InjectCheckbox = "last";
                gp.SelectionModel.Add(csm);
                gp.StoreID = "SUBMIT_EVIDENCE_STORE_ID";
                gp.Render();
    ..... but that results in the gridpanel disappearing totally! Is there any MVC examples? Can I do what I want in this way? As an aside, would it be possible to change from a CheckboxSelection model to a RowSelection model by similar means?
    Last edited by Daniil; Oct 08, 2013 at 6:48 AM. Reason: [CLOSED]
  2. #2
    Hi @ATLAS,

    Please try:
    CheckboxSelectionModel sm = X.GetCmp<CheckboxSelectionModel>("CheckboxSelectionModelId");
    sm.SetSelectionMode(SelectionMode.Single);
    sm.CheckOnly = false;
    Generally speaking, not everything is possible to change on the fly. As for an InjectCheckbox, I don't see an API method to do it. You could try to implement your own JavaScript method to change it on the fly. It might be complicated.

    Quote Originally Posted by ATLAS View Post
    As an aside, would it be possible to change from a CheckboxSelection model to a RowSelection model by similar means?
    I don't think it is possible to change a selection model without re-rendering.

    Well, yes, I see you are trying to re-render:
    gp.Render();
    You are on the right way. I think re-rendering is the only solution for your case since you want to reconfigure many settings.

    Though, calling the Render method in a controller action on the proxy control returned by X.GetCmp is not going to work. X.GetCmp doesn't know about all the GridPanel settings which is defined in the View.

    I would suggest the following. You can load a GridPanel into a Container with a Loader with Mode="Component". If you need to reconfigure a GridPanel, you just reloading a Container with respective parameters.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @ATLAS,

    Please try:
    CheckboxSelectionModel sm = X.GetCmp<CheckboxSelectionModel>("CheckboxSelectionModelId");
    sm.SetSelectionMode(SelectionMode.Single);
    sm.CheckOnly = false;
    Generally speaking, not everything is possible to change on the fly. As for an InjectCheckbox, I don't see an API method to do it. You could try to implement your own JavaScript method to change it on the fly. It might be complicated.



    I don't think it is possible to change a selection model without re-rendering.

    Well, yes, I see you are trying to re-render:
    gp.Render();
    You are on the right way. I think re-rendering is the only solution for your case since you want to reconfigure many settings.

    Though, calling the Render method in a controller action on the proxy control returned by X.GetCmp is not going to work. X.GetCmp doesn't know about all the GridPanel settings which is defined in the View.

    I would suggest the following. You can load a GridPanel into a Container with a Loader with Mode="Component". If you need to reconfigure a GridPanel, you just reloading a Container with respective parameters.

    I have subsequently tried :-

    gp.Reconfigure();
    which causes the gridpanel "box" to be rendered except that the only column to be rendered is the checkbox column ...... and is is only ever in the leftmost column, even when I specify "last". Ah, but if it is only rendering that column, it is aways going to be 0 or "last"!
  4. #4
    The reconfigure method is to change a store and columns. It doesn't suite a requirement to change a grid's selection model.
    http://docs.sencha.com/extjs/4.2.1/#...od-reconfigure

Similar Threads

  1. Replies: 7
    Last Post: Sep 19, 2017, 11:27 PM
  2. Replies: 10
    Last Post: Apr 19, 2013, 3:16 PM
  3. Replies: 3
    Last Post: Oct 05, 2012, 11:44 AM
  4. Replies: 2
    Last Post: Aug 09, 2011, 10:38 AM
  5. Replies: 4
    Last Post: Oct 06, 2010, 9:08 AM

Posting Permissions