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

newly added row delete when switch to other row edit mode (without updating the current row)

0 Answers 294 Views
Grid
This is a migrated thread and some comments may be shown as answers.
fayaz
Top achievements
Rank 1
fayaz asked on 21 May 2012, 02:16 PM
i m facing one problem which is explain below..
i have used all the default actions of kendo grid (inline editor) and its working fine... but there is some problem in 'adding new record'
when i click on 'add new record' , in event 'edit' i check wheather its new row or previsouly added row. if its new row i assign its unique id and my unique field (predicate_id) from the global variable like this
edit: function(e) {
            var uid = e.model.uid;
           if (e.model.id == "") {
                e.model.id = PredicateListCounter;
               e.model.predicate_id = PredicateListCounter;
               PredicateListCounter++;
}

so when i add new record and edit any other row so the newly created row will be deleted (THIS IS DEFAULT - OK)
BUT
once i update the new added row and than click edit (so it will open inline edit mode) and without clicking update if i click on any other row edit button, SO THE NEWLY CREATED ROW DELETE FROM THE DATASOURCE

i uses the following event to use default behavior with little modification from

- dataBound : to bound the dropdowns and its list every time
- edit : too give new unique id to the row
- save : to make changes on other column (like if column 'Operator has value == '$NEAR' so column 'meters' should display its value else display empty)

can anyone plz tell me where i m going wrong... the bug is for sure is while adding new row to the datasource .. what major should take when assigning id to the new row...

i use global variable which assign values to model.id and model.predicate_id (my field)
here is the datasource and grid initalization :
var PredicateDataSource= new kendo.data.DataSource({
        data:PredicateData,
        schema:{
            model:{
                id:"predicate_id",
                fields:{
                    data_type:{ type:"string" },
                    lhs_source:{ type:"string" },
                    lhs:{ type:"string" },
                    operator:{ type:"string" },
                    rhs_source:{ type:"string" },
                    rhs1:{ type:"string" },
                    rhs2:{ type:"number" }

                }
            }
        }
    });
 var predicate_grid = $("#Predicate_Grid").kendoGrid({
        dataSource: PredicateDataSource,
        toolbar: [{ name: "create", text: "Add Condition"}],
        sortable:false,
        scrollable:false,
        batch: true,
        editable:"inline",
        columns:[
            {title:"LHS", field:"lhs_source", editor:LoadAdvPredicate_LHS, width:80},
            {title:"Property", field:"lhs", editor:LoadAdvPredicate_LHS_Property, width:150},
            {title:"Operator", field:"operator", editor:LoadAdvPredicate_Operator, width:100},
            {title:"RHS", field:"rhs_source", editor:LoadAdvPredicate_RHS, width:80},
            {title:"Property", field:"rhs1", editor:LoadAdvPredicate_RHS_Property, width:150},
            {title:"meters", field:"rhs2", editor:LoadAdvPredicate_Meters, width:80},
            { command: ["edit", "destroy"], title: "&nbsp", width: "180px" }

        ]

In short... when add new row and open its edit mode (click on edit) and than edit any other row (without clicking update on prev row which was open in edit mode) the newly created row deleted instead of calling row.cancelChanges();

No answers yet. Maybe you can help?

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