This is a migrated thread and some comments may be shown as answers.

Unable To add row when filtering

1 Answer 621 Views
Grid
This is a migrated thread and some comments may be shown as answers.
None
Top achievements
Rank 1
None asked on 28 May 2015, 04:03 AM
I have a nested grid and am having some issues. In my nested grid I need to allow the user to create a new entry. This works perfectly fine if I don't have a  filter for my datasource. If I add one though, when I press "Create Row", nothing happens. No error or message. There is just no new row that is added to the grid. Here is my code:


function detailInit(e) {
      
    var detailRow = e.detailRow;
    console.log("detailRow");
    console.log(e);
    console.log(e.detailRow);
 
 
    detailRow.find(".tabstrip").kendoTabStrip({
        animation: {
            open: { effects: "fadeIn" }
        }
    });
 
    detailRow.find(".AppendLogGrid").kendoGrid({
        dataSource: {
            transport: {
                read: {
                    url: crudServiceBaseUrl + "api/Logging/GetAllLogAppends",
                    dataType: "json"
                },
                update: {
 
                    url: function (data) {
                        console.log("DATA TEST");
                        console.log(data);
                        return crudServiceBaseUrl + "api/Logging/PutLogAppend";
                    },
 
                    dataType: "json",
                    data: function (data) {
                        console.log("returning data in update TEST");
                        console.log(data.models[0]);
                        return data.models[0];
                    },
                    type: "PUT",
                    contentType: "application/json",
 
                },
                destroy: {
                    url: crudServiceBaseUrl + "api/Logging",
                    dataType: "json"
                },
                create: {
                    dataType: "json",
                    type: "POST",
                    contentType: "application/json",
                    url: function (data) {
                        console.log("INSIDE CREATE URL");
                        console.log(data);
                        console.log(data.models[0]);
                        return crudServiceBaseUrl + "api/Logging/PostLogAppend?ParentLogID=" + e.data.id;
                    },
                    data: function (data) {
                        console.log("CREATING TEST DATA");
                        console.log(data.models[0]);
 
                        return data.models[0];
                    }
 
                },
 
                parameterMap: function (model, operation) {
                    if (operation !== "read" && model) {
                        return kendo.stringify(model);
                    } else {
                        return kendo.stringify(model);
                    }
                }
            },
            // filter: { field: "LOG_FK", operator: "eq", value: e.data.id }, THIS IS THE ISSUE!!!!!
            batch: true,
            pageSize: 20,
            schema: {
                data: function (data) { 
                    console.log("Log append return data:");
                    console.log(data);
                    console.log(e.data);
                    console.log(e.data.$id);
                    return data || [];
                },
                model: {
                    id: "Id",
                    fields: {
                        Id: {
                            editable: false,
                            nullable: false,
                            type: "number"
                        },
 
                        Comments: { type: "string" },
                        DateAppended: { type: "date" },
                        Type: { type: "string" },
                        LOG_FK: { type: "number" }
 
                    }
                }
            }
 
        },
         
        scrollable: false,
        sortable: true,
        pageable: true,
        toolbar: ["create"],
        editable: "inline",
        columns: [
            { field: "Id", width: "110px" },
            { field: "Comments", title: "Comments", width: "110px" },            
              { command: ["edit", "destroy"], title: " ", width: "250px" }
        ]
    });
 
 
}
 
$("#IncidentLoggingGrid").kendoGrid({
    dataSource: LoggingDS,
 
    columns: [         
        { field: "Comments", template: "<textarea rows='4' cols='40'>  </textarea>  ", title: "Comments", format: "{0:c}", width: "200px" },   
 
        { command: ["edit", "destroy"], title: " ", width: "250px" }
    ],
    detailTemplate: kendo.template($("#AppendLogGridTemplate").html()),
    detailInit: detailInit,
    dataBound: function () {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    },
    toolbar: ["create"],
    editable: "inline",
    pageable: true
 
});


I don't know what else to try. Thanks for any help.

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 01 Jun 2015, 05:19 AM
Hello Matt,

Current behavior is expected when the "serverFiltering" option is disabled (by default is set to false) - in this case when you create new record and the default values doesn't match the applied filter the record will not be shown. There are several ways to achieve the desired behavior - for example you enable server filtering or set function as default value in the dataSource "schema.model.fields.field" option (in this case you can automatically set the initial value of the new record to match the applied filter):

 
Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
None
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or