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

Grid popup edit don't display 'null'

0 Answers 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 21 Aug 2012, 09:14 PM
I know that you can apply a template to a field in the grid to display an empty string instead of a null, but can you do the same thing for the resulting field in the popup edit window?  The following is what I have, but is filling the Address2 textbox with 'null' when the popup is displayed.

$(document).ready(function () {
                        dataSource = new kendo.data.DataSource({
                            transport: {
                                read: {
                                    url: "@Url.Action("Read", "Address")"
                                },
                                update: {
                                    url: "@Url.Action("Update", "Address")",
                                    type: "POST",
                                    complete: function(data) {
                                           $('#grid').data('kendoGrid').dataSource.read();
                                           alert("Address successfully updated");
                                        }
                                },
                                  parameterMap: function(data, operation) {
                                    if (operation != "read") {
                                        // post the products so the ASP.NET DefaultModelBinder will understand them:
                                        var result = {};
                                        for (var i = 0; i < data.models.length; i++) {
                                            var address = data.models[i];
                                        }
                                        return address;
                                    }
                                }
                            },
                            batch: true,
                            pageSize: 30,
                            schema: {
                                model: {
                                    id: "AddressID",
                                    fields: {
                                        AddressID: { editable: false, nullable: false },
                                        Address: { type: "string", validation: { required: true} },
                                        Address2: {
                                            type: "string",
                                            template: "#= (Address2 == 'null') ? ' ' : Address2 #"
                                        },
                                        City: { type: "string" },
                                        State: { type: "string" },
                                        Zip: { type: "string" },
                                    }
                                }
                            }
                        });

            $("#grid").kendoGrid({
                dataSource: dataSource,
                pageable: true,
                height: 400,
                columns: [
                            { field: "Address", title: "Address", width: "250px" },
                            { field: "Address2", title: "Address2", width: "200px"
                                , template: "#= (Address2 == 'null') ? ' ' : Address2 #"
                            },
                            { field: "City", width: "100px" },
                            { field: "State", width: "100px", maxlength: "2" },
                            { field: "Zip", width: "100px" },
                            { command: ["edit", "destroy"], title: "&nbsp;", width: "210px"}],
                editable: "popup"               
            });
        });

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Share this question
or