Results 1 to 2 of 2

Thread: grid bind to object

  1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    15
    Vote Rating
    0
      0  

    Question grid bind to object

    hi, i've a question;
    i'm trying to bind grid to formPanel but how can i convert string value to boolean in binding process?
    i would insert some checkbox in formPanel, and when a grid row is binded i would like to see che chechbox
    selected or unselected

    thank you

    this is my code:

    Code:
    final FormBinding formBindings;
            FormPanel panel = createForm();
            formBindings = new FormBinding(panel, true);
            grid= createGrid();
            formBindings.setStore(grid.getStore());
            grid.setPixelSize(500, 350);
            grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
            grid.getSelectionModel().addListener(Events.SelectionChange,
                    new Listener<SelectionChangedEvent<esLogin>>() {
                        public void handleEvent(
                                SelectionChangedEvent<esLogin> be) {
                            if (be.getSelection().size() > 0) {
                                formBindings.bind((ModelData) be.getSelection()
                                        .get(0));
                            } else {
                                formBindings.unbind();
                            }
                        }
                    });
    Code:
    private FormPanel createForm() {
            FormPanel panel = new FormPanel();
            panel.setHeaderVisible(false);
            panel.setHeight(400);
        
            TextField<String> id = new TextField<String>();
            id.setName("id");
            id.setEnabled(false);
            id.setFieldLabel(span + "ID</span>");
            panel.add(id, new FormData(75, 22));
            
            TextField<String> username = new TextField<String>();
            username.setName("username");
            username.setFieldLabel(span +"Username</span>");
            panel.add(username);}

  2. #2
    Sencha User
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737
    Vote Rating
    93
      0  

    Default

    Set a Converter for the Field in question. This can be done by creating a Converter instance with correct implementations for the two methods to convert between the field and the model, and attaching it to the FieldBinding that it belongs to in the FormBinding.

    formBindings.getBindinging(myBoolField).setConverter(myStringToBooleanConverter);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •