[CLOSED] Updating Store from Selected Record in GridPanel

  1. #1

    [CLOSED] Updating Store from Selected Record in GridPanel

    Hi

    I'm sure there must be a simple solution to this but I've spent so much time trying to find it that I need some help.

    I have a GridPanel with a Store and I'm using data from that Store to render a ColorPicker

    Html.X().Panel().Layout(LayoutType.VBox).Width(70).Cls("borderless-panel").Height(120).Hidden(!(bool)SessionHelper.Clients).Items(
              Html.X().DropDownField().ID("VAColour").PickerAlign("bl").Width(50).Height(30).MarginSpec("10 0 0 0")
                    .Component(c => c.Add(
                           Html.X().Container().Height(200).Width(30).AutoScroll(true)
                           .Items(
                            Html.X().ColorPicker().ID("VA").Width(55).Listeners(l => l.Select.Fn = "colourPickSelectHandler")
                       )
                 )
    ),
    The initial colour of the ColourPicker is set like this:

            var selectedRecords = grid.getSelectionModel().getSelection();
            selectedData = selectedRecords[0].data;
              App.VAColour.inputEl.setStyle('color', '#' + selectedData.VAColour);
    When the user selects a different colour I want to be able to update VAColour in the store. I realise I can't just set selectedData but I can't find a way to update the store. It's really frustrating because none of the Ext.js methods seem to work!

    Thanks for your help

    Jeff
    Last edited by fabricio.murta; Mar 22, 2016 at 11:20 PM. Reason: no user feedback for 7+ days
  2. #2
    Hello Jeff!

    I've tested here on this example: Row Selection in GridPanels. With this code, I could catch the first selected row's record, and update its value in the grid:

    var sm = App.GridPanel1.getSelectionModel();
    var sel = sm.getSelection();
    var rec = sel[0];
    
    // at this point, we could get rec.data.PctChange and store somewhere, much like you already do with the color on the picker.
    
    var newValue = 2;
    
    // after we have a new value we want to write and update in the grid, this works:
    rec.set("PctChange", newValue);
    I really hope this is the easy solution out of this problem you were looking for! :)
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Thanks Fabricio

    This is what I understood and what I was doing. However, in my particular setup it wasn't working.

    I have now discovered why it wasn't working and found a workaround. I think there's probably a bug in there somewhere. Unfortunately I don't have time at the moment to replicate it in a simple environment.

    Thanks

    Jeff
  4. #4
    Hello Jeff!

    Just a thought to share then. If you are using groups on your grid panel, there was a recently resolved problem that applied for 3.2.1 and fixed on 3.3.0 and 4.0.0. But I believe you completely switched your project to 3.3.0 already, right?
    Fabrício Murta
    Developer & Support Expert
  5. #5
    Hi Fabricio

    Yes, we're using 3.3.0 on all projects now.

    Regards

    Jeff

Similar Threads

  1. [1.0] Selected Record in a GridPanel
    By walle in forum 1.x Help
    Replies: 3
    Last Post: Nov 26, 2013, 1:34 AM
  2. GridPanel submit selected record
    By Qulei in forum 2.x Help
    Replies: 1
    Last Post: Nov 12, 2013, 4:22 AM
  3. [CLOSED] Data Store not updating record mapping from codebehind
    By sadaf in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 08, 2010, 4:42 PM
  4. How to get id of record for selected row in GridPanel?
    By Yanfang Wang in forum 1.x Help
    Replies: 2
    Last Post: Jun 13, 2010, 3:06 AM
  5. Updating GridPanel Store in AjaxEvent
    By niceguymattx in forum 1.x Help
    Replies: 2
    Last Post: Mar 10, 2010, 5:36 AM

Posting Permissions