Skip to content

Replies

0
Kyle
Kyle answered on Sep 22, 2014 6:37 PM

We also eventually needed a solution that would allow the user to make edits in the grid and see those changes reflected in the export.  We settled on a little utility called jQuery File Download Plugin.  Might be worth a try for you:

https://github.com/johnculviner/jquery.fileDownload

You wire up an export button on your page to an ajax call, something like this:

function exportItems() {
    var items = { items: $('#igGrid').igGrid('option', 'dataSource').Records };
    $.fileDownload('Excel/ItemExport', {
        httpMethod: "POST",
        data: items
    });
}

Then in your SendForDownload() method, you include this statement:

Response.SetCookie(new HttpCookie("fileDownload", "true") { Path = "/" });

There are probably many other ways to make this work, but this approach ended up working fine for us.

0
Kyle
Kyle answered on May 22, 2014 11:53 PM

Thanks Maya, that helps a lot!

0
Kyle
Kyle answered on May 13, 2014 5:52 PM

Sorry, but one last question came up, Maya.  I'm writing this with the MVC helper, and I think I may have gotten something lost in translation.  Here's the code I was trying out:

colSetting.ColumnSetting().ColumnKey("Name")

.Required(true)

.EditorOptions("checkValue:validate()");

In a separate script file, I have the validate function defined like this:

function validate(evt, ui) {

}

When I set it up that way and put a breakpoint on my validate function, I see that it is only called once when the grid loads, but never again when I finish editing a row.  Did I use the MVC helper properly in this case?  Is it a situation where I need to define the function in-line in the MVC helper?

EDIT:  I think I realized my mistake after checking Maya's example a little more closely.  I needed my EditorOptions call to look like this:

.EditorOptions("validatorOptions:{checkValue:validate}");

So, another question that has come to mind is how this might work in a hierarchical grid.  Say that my grid is nested 3 layers within an overall ighierarchicalgrid, but I still only want to check for unique values on the 3rd level grid (in other words, duplicates could be allowed, but only if they appear at different levels in the hierarchy).  I had a couple of ideas on how to alter Maya's example, but I haven't come up with quite the right answer yet.

In the validate function, I'd like the following line to pull out only the rows from one of the nested grids:

var rows = $("#grid").igGrid("rows");                    

But I'm having trouble writing the correct jQuery selector.  When I review the mark-up of my grid in the browser, I notice that the grid I need has an attribute called data-level=3.  It also has it's own id, which looks something like ''Grid_14_Locales_child".  Would either of those be the natural way to get the relevant rows for comparison?

0
Kyle
Kyle answered on May 13, 2014 3:51 PM

Thanks Maya, that's just what I was looking for.

0
Kyle
Kyle answered on Feb 10, 2014 12:46 AM

Thanks Troy,

in the end what seemed to work best for me is to simply use the Session cache to store the contents of the query when it is initially executed.  Then, after the grid is displayed and the user clicks the Export to Excel button, I can just pull the contents from cache and use the Infragistics sample code to transform it to xlsx.  The approach does have a couple of weaknesses, but I think it will cover my use case just fine.

If I need to return to this problem, I'll definitely consider the two resources you posted.  I read through them, and they both seem pretty interesting.

Thanks!

0
Kyle
Kyle answered on Feb 1, 2014 3:17 AM

Hi Troy, thanks for the response.  What I'm really trying to get at is the ability to export the contents of the grid without having to repeat the database query which produced the grid in the first place.  That seems to be the way it's done in the interactive example.

Since all of the grid rows exist client-side after the page is initially rendered, I was hoping to just package it up and post it back to the server to be transformed into an xlsx without needing to query the database again.  That's where I was trying to go with the ajax call.  I'm totally okay with having the standard browser dialog pop-up (save as, open, cancel, etc).  

Please let me know if anything about my scenario is unclear.  It's highly possible I'm going about this in a weird way (I don't normally do web development, so the stateless world of http GETs and POSTs isn't very intuitive for me sometimes).

0
Kyle
Kyle answered on Jan 24, 2014 8:17 PM

Thanks Troy, I appreciate the support.  I'll look forward to your next post.