0

My question is relative to an update of my grid. Here is my current program of grid generation :

leTle[0] = {index : 1, tle : tleId, nom : nomChamp, estar : "", fige : tleFixe, position : positionParam, longueur : longueurParam};               

   var fige;

   if (tleFixe == "true")
        fige = true; 
   else
        fige = false;

    $("#" + theId).kendoGrid({
        columns:[{
                    field: "index",
                    title: "Index",
                    template: "<span style='font-size: 12px;' title='#= index #'>#= index # </span>",
                    width: 40
                },{
                    field: "tle",
                    title: "TLE Id",
                    template: "<span style='font-size: 12px;' title='#= tle #'>#= tle # </span>",
                    width: 100
                },{
                    field: "nom",
                    title: "Intitulé",
                    template: "<span style='font-size: 12px;' title='#= nom #'>#= nom # </span>"
                },{
                    field : "position",
                    title : "Position",
                    width : 70,
                    attributes : {
                        "class" : fige ? " " : "fondRougePale"
                    }
                },{
                    field : "longueur",
                    title : "Longueur",
                    width : 70,
                    attributes : {
                        "class" : fige ? " " : "fondRougePale"
                    }
                },{
                    field :"estar",
                    title :"Estar",
                    template: "<span class='eStar'><input class='inputeStar' disabled type='text' /> </span>",
                    width : 250
                },{
                    command: {
                        name : "destroy",
                        template: "<a class=\"btn btn-warning btn-mini k-grid-delete\">"
                                + "<i class=\"icon-minus-sign icon-white\"></i></a>"
                    },

                    title: " ",
                    width: 40
                }
        ],
        dataSource: {
          data: leTle,
          schema: {
              model: {
                  fields: {
                      tle: {editable: false},
                      nom: {editable: false},
                      estar: {editable: false},
                      longueur: {editable: fige},
                      position: {editable: fige}
                  }
              }
          }
        },
        editable:  {
            mode: "incell",
            confirmation: false
        },
        scrollable : false
    });

As you can see, some of my cell can be disabled if my variable "fige" is equals to false. When I try to build my grid with a basic datasource write manually, the grid is okay. Row after row, when the cell have to be disabled, they are.

Unfortunately, when I try to add rows after the construction of the grid, my variable is never including when the cells are set.

Here is the code :

var vgrid = $("#tleSelected").data("kendoGrid");
            var datasource = vgrid.dataSource;
            var nbLines = vgrid.dataSource.total();
            //Booleen de test
            if (fige == "true")
                tfige = true; 
            else
                tfige = false;
            var newRecord = { index : nbLines+1, tle : tleId, nom: nomChamp, estar: "", position: position, longueur: longueur, fige: tfige}
            datasource.insert(newRecord);

So, I am in a situation where my variables are good, but the new lines are not.

Instead of destroying my grid and rebuild them after an update of data, do you know a solution for this case ?

Thanks a lot.

4

2 に答える 2

0

最後に、この問題の代替ソリューションを見つけました。

変数「fige」は、セルを選択したときに編集できる変数です。KendoUi を使用する代わりに、独自のソリューションを作成することを好みました。

「位置」と「長さ」の列を作成すると:

{
    field : "position",
    title : "Position",
    width : 70,
    template : "<span class='position#= index #' ><input style='width:70px' type='text' value='#= position#' #= readOnly(fige) # /></span>"
},{
    field : "longueur",
    title : "Longueur",
    width : 70,
    template : "<span class='longueur#= index #'><input style='width:70px' type='text' value='#= longueur#' #= readOnly(fige) # /></span>"
}

そして readOnly(fige) 関数:

function readOnly(fige)
{  
    if (fige == "true")
        return "readonly";
    else
        return ""; 
}

この関数のおかげで、動的に、編集可能または編集不可のセルを取得します。KendoUI のデフォルト ソリューションほど良くないかもしれませんが、KendoUI のおかげでこの特定の機能が可能になるとは思いません。

于 2013-10-30T11:19:32.163 に答える