Accessing dataItem from outside dataSource function

3 posts, 0 answers
  1. Mark
    Mark avatar
    3 posts
    Member since:
    May 2016

    Posted 10 May 2016 Link to this post

    I have an AngularJS page, and have a populated dataItem. No problem. Now, I would like to populate a dropdown with one of the columns. I can't quite figure out how to do this. Here is my current code. I have hardcoded the dropdown values but would like to populate it instead from the "ticker" column in the dataItem instead. I think this should be super-easy, right?

     

    $scope.positionGridOptions = function(dataItem) {
     
        return {
            dataSource: {
                type: "xml",
                transport: {
                    read: function(options) {
                        $.ajax({
                            url: "http://fraitcf1vd2607.de.db.com:2701/WS_GetPositionsV3?startDate=" + dataItem.filterStart + "&endDate=" + dataItem.filterEnd + "&fiId=" + dataItem.swapId + "&maxRows=1000",
                            dataType: "xml",
                            success: function(result) {
                                options.success(result);
                            },
                            error: function(result) {
                                options.error(result);
                            }
                        });
                    }
                },
                schema: {
                    type: "xml",
                    data: "/root/row",
                    model: {
                        fields: {
                            ticker: {field: "@ticker", type: "string" },
                            longShort: {field: "@longShort", type: "string" },
                            legId: {field: "@legId", type: "number" },
                            instrId: {field: "@instrId", type: "number" },
                            qty: {field: "@qty", type: "number" },
                            thisDay: {field: "@thisDay", type: "string" }
                        }
                    }
                },
                serverPaging: false,
                serverSorting: false,
                serverFiltering: false,
                pageSize: 20
            },
            sortable: {
                mode: "multiple",
                allowUnsort: true
            },
            height: 200,
            scrollable: false,
            sortable: true,
            groupable: true,
            pageable: { buttonCount: 4 },
            filterable: {
                extra: false,
                operators: {
                    string: {
                        startswith: "Starts with",
                        eq: "Is equal to",
                        neq: "Is not equal to"
                    }
                }
            },
            columns: [
                {field: "ticker", title: "Ticker", width: "50px", filterable: {ui: $scope.ticker3Filter} },
                {field: "longShort", title: "Long/Short", width: "50px", filterable: false},
                {field: "legId", title: "Leg ID",  width: "50px", filterable: false},
                {field: "instrId", title: "Instr ID", width: "50px", filterable: false},
                {field: "qty", title: "Quantity", width: "50px", filterable: false},
                {field: "thisDay", title: "Day", width: "50px", filterable: false}
                ]
            };
        };
         
        // How to get the ticker element for each row in dataItem?
        $scope.ticker3Filter = function(element) {
            element.kendoDropDownList({
            optionLabel: "--Select Value--",
            dataSource: ["ABC.AX","AGL.AX","AHD.AX","AHE.AX"]
         });
        }      

  2. Mark
    Mark avatar
    3 posts
    Member since:
    May 2016

    Posted 10 May 2016 in reply to Mark Link to this post

    Actually, a slight clarification. I want to get the ticker column which is in the result set, inside the scope of the positionGridOptions function.
  3. Mark
    Mark avatar
    3 posts
    Member since:
    May 2016

    Posted 11 May 2016 in reply to Mark Link to this post

    Never mind. I figured it out. I went back out the server and got the filters:

    $scope.ticker4Filter = function(element) {
        element.kendoDropDownList({
        dataTextField: "ticker",
        dataValueField: "field",
        dataSource: new kendo.data.DataSource({
            type: "xml",
            transport: {
                read: function(options) {
                    $.ajax({
                        url: "http://fraitcf1vd2607.de.db.com:2701/WS_GetFiltersV3?startDate=" + $scope.filterStart + "&endDate=" + $scope.filterEnd + "&fiId=" + $scope.swapId + "&maxRows=100",
                        dataType: "xml",
                        success: function(result) {
                            options.success(result);
                        },
                        error: function(result) {
                            options.error(result);
                        }
                    });
                }
            },
            schema: {
                type: "xml",
                data: "/root/row",
                model: {
                    fields: {
                        ticker: {field: "@ticker" }
                    }
                }
            }
        }),
        optionLabel: "--Select Value--"
    });

Back to Top