1

I'm trying to implement shield ui Popup Editing with wicket and java. My html and java code:

<div id="grid2">
<script type="text/javascript">
$(document).ready(function () {
    $("#grid2").shieldGrid({
        dataSource: {
            /*remote: {
                    //read: ""
                    //return "Leyendo";
            },*/
            data: "datasource",
            schema: {
                fields: {
                    ID: { path: "ID", type: Number },
                    Name: { path: "Name", type: String },
                    Age: { path: "Age", type: Number },
                    BirthDate: { path: "BirthDate", type: Date },
                    Active: { path: "Active", type: Boolean }
                }
            }
        },
        paging: {
            pageSize: 15
        },
        rowHover: true,
        columns: [
           { field: "Name", title: "Nombre"},
            { field: "Age", title: "Direccion", width: "100px" },
            { field: "BirthDate", title: "Fecha", format: "{0:dd/MM/yyyy}" },
            { field: "Active", title: "Activo", width: "70px" },
            {
                width: 150,
                title: "Modificar ",
                buttons: [
                    { commandName: "edit", caption: "Editar" },
                    { commandName: "delete", caption: "Eliminar" }
                ]
            }
        ],
        editing: {
            enabled: true,
            mode: "popup",
            confirmation: {
                "delete": {
                    enabled: true,
                    template: function (item) {
                        return "Eliminar abastecimiento con id '" + item.Name + "'?";
                    }
                }
            }
        },
        toolbar: [
            {
                buttons: [
                    { commandName: "insert", caption: "Agregar" }
                ],
                position: "top"
           }
        ]
    });
});
</script>
</div>


<p></p>
</div>

Java's code is:

DataSource datasource = new DataSource("datasource");
DataSourceOptions options = datasource.getOptions();

options.setData(
        new HashMap() {{
                  put("ID", 1);
                  put("Name", "Item1");
                  put("Age", 45);
                  put("BirthDate", "16/08/2006");
                  put("Active", false);
        }},
        new HashMap() {{
                  put("ID", 2);
                  put("Name", "Item2");
                  put("Age", 45);
                  put("BirthDate", "16/08/2006");
                  put("Active", false);
        }},
        new HashMap() {{
                  put("ID", 3);
                  put("Name", "Item3");
                  put("Age", 45);
                  put("BirthDate", "16/08/2006");
                  put("Active", false);
        }},
        new HashMap() {{
                  put("ID", 4);
                  put("Name", "Item4");
                  put("Age", 45);
               put("BirthDate", "16/08/2006");
                  put("Active", false);
        }}
);

add(datasource);
//END testing shieldui          

There is no documentation about implementing datasource for grid editting so I've tried all combinations using remote and datat tags in order to get the data from may java code. No success.

When I deploy my war I get a grid whith several rows with current date in field BirthData but all other fields empty.

I dont know where that data comes, if I remove data:"datasource" from html file i get only grid headers, no data.

Please any suggestion will be grateful.

  • To implement editing, you have to use the DataSource's remote settings - implemented here: https://github.com/shieldui/wicket-shieldui/blob/master/wicket-shieldui/src/main/java/com/shieldui/wicket/datasource/DataSourceOptions.java#L336 – Vladimir Georgiev Aug 22 '17 at 15:41
  • You will also need to implement server endpoint(s) for reading, creating, updating and deleting the data, and link all DataSource remote handlers to those endpoints, as shown in this section of examples: http://demos.shieldui.com/web/grid-editing/editing-restful-web-service – Vladimir Georgiev Aug 22 '17 at 15:42
  • 1
    Thanks for your links Vladimir, I'll review them. – Juan Chipoco Aug 23 '17 at 20:19

0 Answers0