I'm using MVC 4 and 2013 vol 1 with Visual Studio 2012.
I've had a look at the sample on how to create a row/column template, yet the example purely shows adding HTML as a string to the template.
Is it possible to add an upload control into the column template?
If possible could somebody please provide a code sample on how one would achieve this?
Thanks
Hi Greg,
It is possible, but it will affect the performance of the page, because for every grid row it will initialize a new instance of igUpload. Personally I would not choose this approach because of this drawback.
However I'm attaching a sample which demonstrates how to put igUpload in a column template. Basically I put a placeholder with unique id in the grid column and initialize igUpload after the grid finishes initialization. Note that I initialize all igUploads at once with a multiple selector.
You may also want to check out another forum post related to igUpload on how to add custom data to the upload: https://www.infragistics.com/community/forums/f/ignite-ui-for-javascript/80086/igupload-addfinishinguploadeventhandler---user-is-null-in-event/403957#403957
Hope this helps,Martin PavlovInfragistics, Inc.
Thank you for the response Martin, although my requirement is to have this in the grid with an MVC wrapper.After looking at your sample, I am trying to define the template column for the file upload like so... but I'm not sure how in the column declaration to get the current Id of the current row...
.Columns(column => { column.For(x => x.id).HeaderText("ID").Width("100px").Hidden(true); column.For(x => x.name).HeaderText("Name").Width("250px");column.For(x => x.fileparth).Width("300").Template("<\div id='" + ?? + "' class='upload-control'></\div>");
})
In addition to that, what field do I map x to? I have it currently mapped to filepath, which is a string, but I'm not sure if that is correct.
Template is executed in the browser so you should put the following code:
.Columns(column =>{column.For(x => x.id).HeaderText("ID").Width("100px").Hidden(true);column.For(x => x.name).HeaderText("Name").Width("250px");column.Unbound("UploadColumn").Width("300px").Template("<div id='${id}' class='upload-control'></div>");
Note that instead of filepath I used an unbound column.
And you code to initialize the igUpload should be in JavaScript below the Grid initialization code. like this:
<script type="text/javascript">
$(function() {
$("#grid1 .upload-control").igUpload({});
});
</script>
Thank you very much I have gotten it working Martin.
For some strange reason though if I had a reference to /Infragistics/js/modules/infragistics.ui.upload.js
I got an error on the page. But I assume this is something to do with the loader loading twice.
Thank you again for your help, much appreciated.