سؤال

I am making a slick grid and need the ability to add rows with a code column. For this to be possible the code column needs to be editable for the entire table.

I am trying to work out a way that I can confirm the edit with a standard javascript confirm popup box. I tried putting one into the onedit event within the slickgrid constructor and that executed after the edit.

I am led to believe that the edit function is independent from calling the edit stored procedure of the database. Is there a better way to go about this?

RF_tagsTable = new IndustrialSlickGrid(
    LadlesContainerSG
    , {
        URL: Global.DALServiceURL + "CallProcedure"
    , DatabaseParameters: { Procedure: "dbo.TableRF_tags" , ConnectionStringName: Global.ConnectionStringNames.LadleTracker }
    , Title: "RF tags"
    , Attributes: {
            AllowDelete: true
        , defaultColumnWidth: 120
        , editable: true
        , enableAddRow: true
        , enableCellNavigation: true
        , enableColumnReorder: false
        , rowHeight: 25
        , autoHeight: true
        , autoEdit: false
        , forceFitColumns: true
    }
    , Events: {
        onRowEdited : rowEdited
                    /*function(){    //this is my failed attempt
                        var r=confirm("Edit an existing tag?")
                        if (r){
                            alert(r);
                        } else {
                            alert(r);
                        }
                    }*/
        , onRowAdded : rowAdded
    }
});
هل كانت مفيدة؟

المحلول

If I understand your question correctly (you want to confirm your edit before applying your value to the grid), you should write a custom Editor for your code column. Then you have control absolute over user input.

You can also intercept all cell edits and have complete control over how and when those edits are committed by specifying a custom handler by setting the editCommandHandler grid option.

See this for further reference.

نصائح أخرى

An editCommandHandler is a more appropriate mechanism for this.

See http://mleibman.github.io/SlickGrid/examples/example3b-editing-with-undo.html.

You can use OnBeforeEdit,

grid.onBeforeEditCell.subscribe(function(e,args) {
     \\if true is returned it will edit the cell othewise not
  }
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top