We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

how to open file upload dialog to upload file on cell click in normal edit mode

Hello,

I have successfully applied the method you suggested in thread 128331, but I have a problem.

After uploading the file, I would like the name of the uploaded file inside the grid cell, instead I see the Browse button.

When I save on the SAVE button, the Update method read a null value (and not the file name) on the cell value.

Ideally, I would like to have a cell with this template:

the file name with beside a browse button that opens the uplod dialog.

my parent/child grid is this:

//PARENT GRID
@(Html.EJ().Grid
("MapLevelsGrid")
.Datasource(ds => ds.Json((IEnumerable)Model.MapLevels.ToList()).UpdateURL("../NormalMapLevelUpdate").InsertURL("../NormalMapLevelInsert").RemoveURL("../NormalMapLevelDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit =>
{
edit.AllowAdding().AllowDeleting().AllowEditing();
})
.Locale("it-IT")
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
.AllowResizing()
.AllowTextWrap(true)
.Columns(col =>
{
col.Field("MapLevelId").HeaderText("ID Riga").HeaderTextAlign(TextAlign.Center).IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(100).Visible(true).Add();
col.Field("MapId").DefaultValue(@Model.MapId).HeaderText("ID Mappa").HeaderTextAlign(TextAlign.Center).IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(100).Visible(true).Add();
col.Field("MapLevelCode").HeaderText("Codice (Univoco)").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(100).Visible(true).Add();
col.Field("MapLevelTitle").HeaderText("Titolo").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(100).Visible(true).Add();
col.Field("MapLevelFileName").HeaderText("File Livello").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).EditTemplate(a => { a.Create("filecreate").Read("fileread").Write("filewrite"); }).Width(100).Visible(true).Add();
col.Field("MinimapLevelFileName").HeaderText("File Minuìiatura Livello").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(100).Visible(true).Add();
})
//CHILDGRID
.ChildGrid(d =>
{
//d.Datasource(ds => ds.URL("ContractVMPage").Adaptor(AdaptorType.UrlAdaptor))
d.Datasource(ds => ds.URL("../GetMapLevelLocationsData").UpdateURL("../NormalMapLevelLocationUpdate").InsertURL("../NormalMapLevelLocationInsert").RemoveURL("../NormalMapLevelLocationDelete").Adaptor(AdaptorType.UrlAdaptor))
.QueryString("MapLevelId")
.EditSettings(edit =>
{
edit.AllowAdding().AllowDeleting().AllowEditing();
})
.Locale("it-IT")
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
.Columns(col =>
{
col.Field("MapLevelLocationId").HeaderText("ID").HeaderTextAlign(TextAlign.Center).IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(100).Visible(false).Add();
col.Field("MapLevelId").HeaderText("ID Livello").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(100).Visible(true).Add();
col.Field("MapLevelLocationCode").HeaderText("Codice (univoco)").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(100).Visible(false).Add();
//col.Field("MapCategoryCode").HeaderText("Categoria").ForeignKeyField("MapCategoryCode").ForeignKeyValue("MapCategoryTitle").DataSource((IEnumerable<object>)ViewBag.MapCategories).HeaderTextAlign(TextAlign.Center).Width(10).Add();
col.Field("MapCategoryCode").HeaderText("Categoria").ForeignKeyField("MapCategoryCode").ForeignKeyValue("MapCategoryTitle").DataSource((IEnumerable<object>)ViewBag.MapCategories).HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Center).Width(100).Add();
col.Field("MapLevelLocationTitle").HeaderText("Titolo").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(100).Visible(true).Add();
col.Field("MapLevelLocationShortDesc").HeaderText("Desc. Breve").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(100).Visible(true).Add();
col.Field("MapLevelLocationDesc").HeaderText("Descrizione").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(100).Visible(true).Add();
col.Field("Xcoord").HeaderText("X").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(100).Visible(true).Add();
col.Field("Ycoord").HeaderText("Y").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(100).Visible(true).Add();
col.Field("ZoomLevel").HeaderText("Zoom").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(100).Visible(true).Add();
col.Field("MapLevelLocationThumbnailFileName").HeaderText("File Miniatura Livello").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(100).Visible(true).Add();
});
})
.ClientSideEvents(eve =>
{
eve.Load("childLoad");
})
.ClientSideEvents(eve =>
{
eve.Load("onLoad");
eve.CellEdit("cellEdit");
eve.TemplateRefresh("TemplateRefresh");
})
)

JAVASCRIPT

    //GESTIONE FILE GRAFICI
    function filecreate() { 
        alert('create');
        return $("
"); 
    } 
 
    function filewrite(args) { 
        var proxy = args; 
        var filename = "";
        alert('write');
        args.element.ejUploadbox({ 
            saveUrl: "/Map/SaveFileName",
            extensionsAllow: ".svg", 
            complete: function (args) { 
                filename = args.files.name;
                this.element.value = filename;
            }, 
            uploadName: "FileUploadBox", 
        }); 
        proxy.element.val(filename);
    } 
 
    function fileread(args) { 
        return args.val(); 
    }

Can you help me?

Thanks.

Claudio

2 Replies

CR CLAUDIO RICCARDI August 11, 2017 04:17 PM UTC

I have noticed that the function fileread is never triggered when I save the record

..I think this is the problem.

Can you help me?

Claudio


PK Prasanna Kumar Viswanathan Syncfusion Team August 14, 2017 12:04 PM UTC

Hi Claudio, 

Thanks for contacting Syncfusion support. 

Before we proceed with this query, we need some clarifications.  

1. In this sample once we uploading the file we see only the browse button. But when we click the save button we can able to save the name of the uploaded file in the grid cell. 

2. Do you want to see file name in grid cell once you uploading the file or when click the save button in Grid? 

3. In our sample we can be able to trigger the read method while save the record. But you have mentioned the read method is never triggered. So, did you face any script error in the console page? If yes, share the screenshot and stackrace. 

4. Essential Studio Version details. 

5. If possible, replicate the issue in the attached sample.   


Regards, 
Prasanna Kumar N.S.V 
 


Loader.
Live Chat Icon For mobile
Up arrow icon