Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    getPickListFilterCriteria not working when datasource is not used

    Code:
                isc.DataSource.create({
                    ID: "category1DS",
                    fields: [
                        { name: "itemCategory1", title: "Category - 1 Code", type: "text" },
                        { name: "itemCategory1Name", title: "Category - 1 Name", type: "text" },
                    ],
                    clientOnly: true,
                    testData: [
                        { itemCategory1: "1", itemCategory1Name: "Computer" },
                        { itemCategory1: "2", itemCategory1Name: "Office" },
                        { itemCategory1: "3", itemCategory1Name: "General" },
                        { itemCategory1: "4", itemCategory1Name: "Paper Works" }
                    ]
                })
    
                isc.DataSource.create({
                    ID: "category2DS",
                    fields: [
                        { name: "itemCategory2", title: "Category - 2 Code", type: "text" },
                        { name: "itemCategory2Name", title: "Category - 2 Name", type: "text" },
                        { name: "itemCategory1", title: "Category - 1", type: "text" }
                    ],
                    clientOnly: true,
                    testData: [
                        { itemCategory2: "1", itemCategory2Name: "Computer Parts", itemCategory1: "1" },
                        { itemCategory2: "2", itemCategory2Name: "Software", itemCategory1: "1" },
                        { itemCategory2: "3", itemCategory2Name: "Accessories", itemCategory1: "2" },
                        { itemCategory2: "4", itemCategory2Name: "Furniture", itemCategory1: "2" },
                        { itemCategory2: "5", itemCategory2Name: "A5 Paper", itemCategory1: "4" }
                    ]
                })
    
                var gridData = [
                        { Id: 1, itemName: "Processor", itemCategory1: "1", itemCategory2: "1" },
                        { Id: 2, itemName: "SSD", itemCategory1: "1", itemCategory2: "1" },
                        { Id: 2, itemName: "Windows 10", itemCategory1: "1", itemCategory2: "2" },
                        { Id: 3, itemName: "Pencil", itemCategory1: "2", itemCategory2: "3" },
                        { Id: 4, itemName: "Table", itemCategory1: "2", itemCategory2: "3" }
                ];
    
                var gridFields = [
                    { name: "Id", hidden: true, primaryKey: true, type: "integer" },
                    { name: "itemName", title: "Item Name", type: "text" },
                    { name: "itemCategory1", title: "Category - 1", type: "text", optionDataSource: category1DS, valueField: "itemCategory1", displayField: "itemCategory1Name" },
                    {
                        name: "itemCategory2", title: "Category - 2", type: "text", optionDataSource: category2DS, valueField: "itemCategory2", displayField: "itemCategory2Name",
                           [B] getPickListFilterCriteria[/B]: function () {
                            var category1 = this.grid.getEditedCell(this.rowNum, "itemCategory1");
                            return { itemCategory1: category1 };
                        }
                    },
                ];
    
                isc.DataSource.create({
                    ID: "itemDS",
                    fields: gridFields,
                    clientOnly: true,
                    testData: gridData
                })
    
                isc.ListGrid.create({
                    ID: "itemGrid",
                    width: 500, height: 224, alternateRecordStyles: true,
    [B]               //dataSource: itemDS, dataSource is not used this situation[/B]
                    autoFetchData: true,
                    canEdit: true
                });
    
                //setting grid fields
               [B] itemGrid.setFields(gridFields);[/B]
    
                //setting grid data
    [B]           itemGrid.setData(gridData);[/B]
                
            };
    SmartClient Version 10.1 Professional.
    Firefox 43.0.4
    Chrome 53.0.2785.143

    For Some obligations, we must used this method ( itemGrid.setFields(gridFields), itemGrid.setData(gridData) ). But getPickListFilterCriteria() function is not wotking when i use this method,

    If I bind itemDS datasource to grid with dataSource property and itemGrid.setFields(gridFields), itemGrid.setData(gridData) lines commented out then getPickListFilterCriteria() function is working very well.

    If you try this code on Feature Examples code panel, you will see same problem.

    Do you have any ideas why was not working getPickListFilterCriteria() function for our way?
    Last edited by eakduman; 11 Oct 2016, 04:10.

    #2
    You do need a DataSource to enable filtering. The system needs field definitions in order to know what to do with criteria. However, you can simply make a clientOnly DataSource from your fields and data. Or, make a DataSource from just the fields, continue to apply the data via setData(), but also set filterLocalData:true.

    Comment

    Working...
    X