[CLOSED] Change Store Datasource in Combo Editor Column inside GridPanel

  1. #1

    [CLOSED] Change Store Datasource in Combo Editor Column inside GridPanel

    Hi,

    I use your example (https://examples1.ext.net/#/GridPane...Field_Mapping/) to change data store asociated to combobox when after edit event is called but neither the store or combobox refresh their data.

    Can you help me?

    Regards!
    Last edited by Daniil; Apr 16, 2012 at 9:23 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Do you need to bind a data to the ComboBox according to a current grid row?

    If so, please look at the example.
    http://forums.ext.net/showthread.php...ll=1#post74887
  3. #3

    How to Get Values From Column Editor in GridPanel?

    thanks for answer daniil.

    I tried with your example but no work.
    Throw the message:

    Uncaught ReferenceError: GridComboStore is not defined 'beforeload',

    I think that i need "var onBeforeEdit = function (e) {..." as DirectMethod, no javascript because the Store is created dynamically.

    How do i do this?

    Regards.

    Quote Originally Posted by Daniil View Post
    Hi,

    Do you need to bind a data to the ComboBox according to a current grid row?

    If so, please look at the example.
    http://forums.ext.net/showthread.php...ll=1#post74887
  4. #4
    How to Get Values From Column Editor in GridPanel?
    Please see the parameters of BeforeEdit listener:
    http://docs.sencha.com/ext-js/3-4/#!...ent-beforeedit

    I use the "e.record" in my example.
    options.params = {
        id : e.record.data.id
    }
  5. #5

    How to Get Values From Column Editor in GridPanel?

    thanks for answer!

    This is how I implemented the editor column.
    This worked fine, just do not find a way to render the column with the text of the combobox.

     private void CreateEditorColumn(.........)
            {
                Column column = new Column
                {
                    ColumnID = columnID,
                    DataIndex = dataIndex,
                    Header = header,
                    Tooltip = tooltip,
                };
    
                if (width > 0)
                {
                    column.Width = width;
                }
    
                if (gridEditableColumnParameters.TypeEditableColumn == TypeEditableColumn.Combo)
                {
                    CreateComboEditorColumn(gridEditableColumnParameters, column);
                }
    
                column.Renderer.Handler = ??????????????
    
                grdGenerica.ColumnModel.Columns.Add(column);
            }
    
    
            private void CreateComboEditorColumn(GridEditableColumnParameters gridEditableColumnParameters, Column column)
            {
                Ext.Net.ComboBox comboEditor = new Ext.Net.ComboBox();
                Store store = new Store { AutoLoad = false, };
                JsonReader reader = new JsonReader();
    
                reader.Fields.Add(new RecordField(gridEditableColumnParameters.ComboDisplayField));
                reader.Fields.Add(new RecordField(gridEditableColumnParameters.ComboValueField));
    
                store.Reader.Add(reader);
                store.Proxy.Add(new PageProxy());
    
                store.RefreshData += new Store.AjaxRefreshDataEventHandler((sender, args) =>
                {
                    Store storeCombo = (Store)sender;
                    string gridSelectedValue = grdGeneric.SelectedValues.First();
    
                    if (gridEditableColumnParameters.OnNeedComboDataSource != null)
                        gridEditableColumnParameters.OnNeedComboDataSource(grdGeneric.SelectedValues.First(), storeCombo);
                });
    
                comboEditor.Store.Add(store);
                comboEditor.DisplayField = gridEditableColumnParameters.ComboDisplayField;
                comboEditor.ValueField = gridEditableColumnParameters.ComboValueField;
                comboEditor.ID = gridEditableColumnParameters.ComboValueField + "_Editor";
                comboEditor.Listeners.BeforeQuery.Fn = "function(qe) { this.store.reload(); }";
    
                column.Editor.Add(comboEditor);
    
                grdGenerica.DirectEvents.AfterEdit.ExtraParams.Add(new Ext.Net.Parameter { Mode = ParameterMode.Raw, Name = "value", Value = "e.value" });
                grdGenerica.DirectEvents.AfterEdit.Event += new ComponentDirectEvent.DirectEventHandler((obj, sender) =>
                {
                    string comboSelectedValue = sender.ExtraParams["value"];
                    string gridSelectedValue = grdGeneric.SelectedValues.First();
    
                    if (gridEditableColumnParameters.OnChangeColumnValue != null)
                        gridEditableColumnParameters.OnChangeColumnValue(gridSelectedValue, comboSelectedValue);
    
                    grdGenerica.Store.Primary.CommitChanges();
                });
            }
    
            public class GridEditableColumnParameters
            {
                public TypeEditableColumn TypeEditableColumn { get; set; }
    
                public Action<string, Store> OnNeedComboDataSource { get; set; }
                public Action<string, string> OnChangeColumnValue { get; set; }
                public string ComboDisplayField { get; set; }
                public string ComboValueField { get; set; }
                public string FieldMappingGridFromCombo { get; set; }
            }
    How to render a grid column text from a combo display value??

    Thanks!
    Regards.


    Quote Originally Posted by Daniil View Post
    Please see the parameters of BeforeEdit listener:
    http://docs.sencha.com/ext-js/3-4/#!...ent-beforeedit

    I use the "e.record" in my example.
    options.params = {
        id : e.record.data.id
    }
  6. #6
    Please ensure the code is wrapped in [CODE ] tags. It's difficult to read.
  7. #7
    You have already mentioned this example:
    https://examples1.ext.net/#/GridPane...Field_Mapping/

    I think a Renderer should look similar to the Renderer of the Department column.
  8. #8

    How to Get Values From Column Editor in GridPanel?

    Daniil,

    I can't render the text like in the example because Store doesn't exists ...

    It throws the message "ReferenceError: GridComboStore" is not defined." when i execute the GridComboStore.getById.

    I don't known how to render the text in the column...

    In the example that you mentioned there is only one store for all the combobox.
    But I have a combo for each row with their own data.

    That's the difference with the example.
    How can i access to the store of the combobox instead of the store of the grid (The renderer function receives an store, but its the one in the grid...)

    Regards!



    Quote Originally Posted by Daniil View Post
    You have already mentioned this example:
    https://examples1.ext.net/#/GridPane...Field_Mapping/

    I think a Renderer should look similar to the Renderer of the Department column.
  9. #9
    Well, could you provide a full runnable sample to test with?
  10. #10

    How to Get Values From Column Editor in GridPanel?

    Hi Daniil,

    I solved my problem as follows:

     column.Renderer.Handler = "return " + this.ClientID + "_cmbColumn_Editor.lastSelectionText";
    thanks!
    Regards.

    Quote Originally Posted by Daniil View Post
    Well, could you provide a full runnable sample to test with?
    Last edited by Daniil; Apr 13, 2012 at 10:39 PM. Reason: Please use [CODE] tags

Similar Threads

  1. GridPanel, Store, DataSource - passing Keys
    By alexua in forum 2.x Help
    Replies: 0
    Last Post: Jul 16, 2012, 8:10 PM
  2. [CLOSED] How to change a column inside a ColumnTree in javascript
    By PhilG in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 27, 2012, 10:33 AM
  3. Replies: 5
    Last Post: Feb 01, 2012, 11:54 AM
  4. [CLOSED] Grid Combo Editor - Make drop-down wider than column
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 02, 2011, 3:05 PM
  5. [CLOSED] ComboBox / Store / DataSource : Store.DataSource is NULL
    By wagger in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Apr 24, 2011, 10:09 AM

Posting Permissions