0

Hi this is the cod of my dGrid html:

        <table id="Assign_Segments" class="dGrid" 
    dojoType="dgrid.GridFromHtml" style="width:700px">
            <tbody>
                <tr>
                    <th data-dgrid-column="{field:'InputCell', sortable:true}">
    <bean:message key="IDD_POPSEG_PAGE.IDC_LBL_INPUTCELL" bundle="flowchart"/>
                    </th>
                    <th data-dgrid-column="dgrid.Editor({field:'Segment', 
    sortable:false, widgetArgs: segmentSelectOptions}, dijit.form.Select, 'click')">
  <bean:message key="IDD_POPSEG_PAGE.IDC_LBL_SEGNAME" bundle="flowchart"/></th>
                </tr>
            </tbody>
     </table>

I have wired them this using the folowing:

dojo.global.segmentSelectOptions = function(object){

    var opts = [{
        'label': 'seg1',
        'value': 'seg1'
    }, {
        'label':'New Segment...',
        'value':'new'
    }, {
        'label': 'seg2',
        'value': 'seg2'
    }];

    return { onChange: function(newValue){
        if(newValue=='new'){
            var dlg =  dijit.getWidget('CreateFolder','dijit.Dialog');
            dlg.show();

        }
    }, 
    class: "fullWidthWidget", 
    options: opts};
};

This code as you can see, opens a dialog. Now I want to access the cell that i have selected in the dgrid when I press a particular button on the dialog and change the value of the cell based on the inputs in the dialog. How do I access the cell from that function? The thing is it could be any cell in the dgrid and they don't have id to use dijit.byId();

Please help me out!

Craig Swing
  • 8,152
  • 2
  • 30
  • 43
MozenRath
  • 9,652
  • 13
  • 61
  • 104
  • Why don't you just pass the grid (or cell if you prefer) as a parameter of your dialog? I would extend dijit.Dialog to make a custom one which would support a grid parameter, that would allow you to extend the Dialog with your own functions to manipulate the grid – PEM May 07 '12 at 07:48
  • as far as passing the cell to the dialog, I have already tried that but when I try to set its value, I get an error saying `cannot set innerHTML of null`. – MozenRath May 07 '12 at 08:01
  • if the cell parameter is null, then it means you haven't passed it properly :) Anyway, try extending the dialog, and add your own stuff in there, it'll make your life easier – PEM May 07 '12 at 08:12
  • the thing is it is not null, I have checked that already. its just that because the function where I try to set the value is called when the dialog is about to close and not when it has been closed. hence dojo is unable to locate the dom node correctly. I will look into the inheritance but am not sure how to do it. – MozenRath May 07 '12 at 08:15

1 Answers1

0

The solution is to give a callback from the hide() of the dialog to a function where you alter the grid. However, you need to use this line before using the put() statement of your store:

grid.dirty = {};
MozenRath
  • 9,652
  • 13
  • 61
  • 104