Refreshing ListGridField

Same thing, just one more level of indirection: pickListProperties inside editorProperties on the ListGridField.

Thanks. I guessed at how to implement your suggestion, and it worked!

Here’s the code, in case anyone needs to see it:

isc.ListGrid.create({
    ID:"magazineList",
    dataSource:"magazineRestDS",
    dataProperties:{useClientFiltering:false},
    fields:[
        {name:"mag_name", title:"Title", showHover:true},
        {name:"mag_number", title:"Number", showHover:true, width:75},
        {name:"mag_contract_id", title:"Contract",
            showHover:true,
            editorType: "select",
            editorProperties: {
                pickListProperties: {
                    sortFieldNum:"contract_name"
                }
            },
            optionDataSource:"contractRestDS",
            autoFetchDisplayMap: true,
            valueField:"contract_id",
            displayField:"contract_name"},
        {name:"mag_add_date", title:"Date Added", align:"center", showHover:true, canEdit:false}
    ],
    alternateRecordStyles:true,
    useCellEvents:true,
    recordClick: "issueFindForm.findIssues(record.mag_id);",
    selectionType:"single",
    canEdit: true,
    editEvent: "doubleClick",
    showFilterEditor: false,
    listEndEditAction: "done",
    autoDraw:false
});

Hi,

I have another ListGrid with a select list field. The select list data (Category) comes from a RestDataSource.

isc.ListGrid.create({
    ID:"fieldGrid",
    dataSource:"fieldRestDS",
	fields:[
		{name:"field_name", title:"Field Name", showHover:true},
        {name:"field_descrip", title:"Field Description", showHover:true},
		{name:"field_cat_id", title:"Category",
			editorType: "select", 
			editorProperties: {pickListProperties:{sortFieldNum:"cat_name"}},
			optionDataSource:"categoryRestDS",
			autoFetchDisplayMap: true,
			valueField:"cat_id",
			displayField:"cat_name"
		},
		{name:"field_qb_fullname", title:"QuickBooks FullName", showHover:true},
		{name:"field_unit1", title:"Qty Units", showHover:true, width:100},
		{name:"field_unit2", title:"Rate Units", showHover:true, width:100}
    ],
    useCellEvents:true,
    selectionType:"single",
	canEdit: true,
    editEvent: "doubleClick",
	autoDraw:false
});

The user can change the category names in a “Category” ListGrid.

isc.ListGrid.create({
    ID:"categoryGrid",
    dataSource:"categoryRestDS",
	fields:[
        {name:"cat_name", title:"Category Name", showHover:true}
    ],
    alternateRecordStyles:true,
    useCellEvents:true,
    selectionType:"single",
	canEdit: true,
    editEvent: "click",
	editComplete: function () {
		fieldGrid.data.invalidateCache();
	},
	autoDraw:false
});

As you can see, in the editComplete I’m trying to refresh the values in the first ListGrid, but it’s not happening.

From the debugger console, I can see that when the first ListGrid does its initial load, it’s performing 2 fetches. One for the select list, and another for the grid itself.

When I call invalidateCache in the editComplete of the Category ListGrid, it’s only doing the regular fetch, and it skips re-fetching the data for the select list.

During the initial load of the first ListGrid, I noticed that a “pre” fetch is performed to the Category data source, with a clientContext set. This must build the selection list before the rest of the ListGrid is drawn.

{
    actionURL:"/gbs/json/categoryRestDS.php?request_type=fetch", 
    showPrompt:true, 
    transport:"xmlHttpRequest", 
    useSimpleHttp:true, 
    promptStyle:"dialog", 
    params:{
        _operationType:"fetch", 
        _dataSource:"categoryRestDS"
    }, 
    httpMethod:"GET", 
    sendNoQueue:true, 
    callback:{
        target:null
    }, 
    serverOutputAsString:true, 
    clientContext:{
        fields:[
            {
                name:"field_cat_id", 
                title:"Category", 
                showHover:true, 
                editorType:"select", 
                editorProperties:{
                    pickListProperties:{
                        sortFieldNum:"cat_name"
                    }
                }, 
                optionDataSource:"categoryRestDS", 
                autoFetchDisplayMap:true, 
                valueField:"cat_id", 
                displayField:"cat_name", 
                $61:true, 
                align:"left", 
                masterIndex:2, 
                width:null, 
                height:null, 
                canDrag:true, 
                canDragResize:true, 
                canAcceptDrop:null, 
                canDrop:false, 
                valueMap:{
                    "2":"Maintenance/Hosting Fees", 
                    "5":"Optional Programs (Setup Fees)", 
                    "16":"Customization Fees", 
                    "17":"Conversion Fees", 
                    "19":"Delivery Fees Test", 
                    "21":"Lead Generation"
                }, 
                $28w:null, 
                $28x:" STYLE='WIDTH:142px;OVERFLOW:hidden;padding-top:0px;padding-bottom:0px;", 
                $28y:"WIDTH:138px;'"
            }
        ]
    }, 
    data:null
}

How do I get this to happen again when I change data in the Category ListGrid?

Thanks,
Mike

One way to force a re-fetch of the valueMap derived from the optionDataSource would be to call setFields() on the fieldGrid, passing the same field definitions you passed on create()

So setFields essentially rebuilds the ListGrid from scratch?

Kind of like what I’m doing with invalidateCache, but taking it a step further, and doing something like an “invalidateFields” ?

Mike

Yes, that’s a reasonable way to look at it.