无法将数组作为二维空数组的属性

时间:2016-05-10 13:52:10

标签: javascript arrays

SELECT
    CASE
        WHEN f.Name IN ('FacultyName1', 'FacultyName2', 'FacultyName3') THEN 'FacultyGroup1'
        WHEN f.Name IN ('FacultyName4', 'FacultyName5') THEN 'FacultyGroup2'
    END AS FacultyGroup,
    COUNT(*) AS Students
FROM 
    Student s
    INNER JOIN Faculty f ON s.FacultyID = f.ID
GROUP BY
    CASE
        WHEN f.Name IN ('FacultyName1', 'FacultyName2', 'FacultyName3') THEN 'FacultyGroup1'
        WHEN f.Name IN ('FacultyName4', 'FacultyName5') THEN 'FacultyGroup2'
    END;

我从选择框中获取numberOfFields变量

 $('#createFields').click(function () {

        for (var i = 0; i <= numberOfFields; i++) {

            fieldsArray[i] = {};
            console.log(fieldsArray);
        };

    });

每次选中复选框时,我都会调用addColumns函数。

$("body").on("change","input:checkbox",
    function () {

        if ($(this).prop('checked')) {

            var val = $(this).prop('value');
            addColumns(val);

        }
        else {

            console.log("deleting...")
            singleArray=singleArray.splice(singleArray.length, newArray.length);
            InitData();
        }
    }
);

不能将concat newArray = [&#39; BBB&#39;,&#39; MMM&#39; CCC&#39;]推送到fieldsArray数组的数组

    function addColumns(val) {
    var defer = $.Deferred();
    newArray = [];
    str = [];

           str.push(val);

           var url = ListJoin.appweburl + "/_api/SP.AppContextSite(@target)/Web/Lists/getbytitle('" + selectedList + "')/items?$select=" + str + "" +
                    "&@target='" + ListJoin.hostweburl + "'";

            ListJoin.executor.executeAsync({
                url: url,
                method: "GET",
                headers: {
                    "Accept": "application/json; odata=verbose"
                },
                success: function (data) {
                    var jsonObject = JSON.parse(data.body);
                    var response = jsonObject.d.results;

                    for (var i = 0, len = response.length; i < len; i++) {
                        var tu = [];
                        var keys = Object.keys(response[i]);
                        //Skip keys[0] because it's always metadata
                        for (var j = 1; j < keys.length; j++) {
                            var key = keys[j];
                            var val = [response[i][key]];
                            console.log("bujar" + val);
                            newArray.push(val);

                        }
                    }

                   fieldsArray[1].push(newArray);

0 个答案:

没有答案