How can catch the dhtmlXgrid error?

The inner errors can be catched in next manner

function myErrorHandler(type, desc, erData){
    //custom code can be placed here
    return false;
}
dhtmlxError.catchError(“LoadXML”, myErrorHandler);

The array contains additonal data related to error
    erData=[xmlHttpRequest , object]

First element - xmlHttpRequest object, which contain all data requested
from server.
Second element - dhtmlx object, component which throw error while
loading.

You can get any additional error info by checking xmlHttpRequest
properties (xmlHttpRequest.responseText for example )

Hi,

I am having 3000 records in my grid, when i am trying to import the grid as EXCEL file. It is not exporting and also its not throwing any error. So, I have placed the below code for error capturing, but its throwing any error. Please help me on to resolve this issue.

function gridConstructor() {
//alert(‘Seating’);
function my_error_handler(type, name, data) {
if (type == “ALL”);
alert(“My error handler \n” + name + “\n Status:” + data[0].status);
}
dhtmlxError.catchError(“ALL”, my_error_handler);

    mygrid = new dhtmlXGridObject('gridbox');
    mygrid.init();
    mygrid.setImagePath("../../Images/dhtmlxGrid/imgs/");
    mygrid.setSkin("dhx_skyblue");

    //enabled column move 
    mygrid.enableColumnMove(true);
    mygrid.enableBlockSelection(true);
    mygrid.enableSmartRendering(true);
    mygrid.forceLabelSelection(true);
    selectFrozenColumnsIfCookie();

}

Are you attempting to import or export data ?
Which code you are are using for that?

Above code snippet shows only grid initialization without any import|export commands.

I am exporting data from DHTML Grid. Please refer the below code.

Index.cshtml

$("#excel").click(function () {
mygrid.setSerializableColumns(“false,false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true”);
mygrid.toExcel(“Generator/GenerateExcel”);
});

Controllers\GeneratorController.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;

using DHTMLX.Export.Excel;
using DHTMLX.Export.PDF;
using System.IO;

namespace Grid2Pdf.Controllers
{
[HandleError]
public class GeneratorController : Controller
{
[HttpPost, ValidateInput(false)]
public ActionResult GenerateExcel()
{
var generator = new ExcelWriter();
var xml = this.Request.Form[“grid_xml”];
xml = this.Server.UrlDecode(xml);
var stream = generator.Generate(xml);
return File(stream.ToArray(), generator.ContentType, “grid.xlsx”);
}

    [HttpPost, ValidateInput(false)]
    public ActionResult GeneratePDF()
    {
        var generator = new PDFWriter();
        var xml = this.Server.UrlDecode(this.Request.Form["grid_xml"]);
        MemoryStream pdf = generator.Generate(xml);
        return File(pdf.ToArray(), generator.ContentType, "grid.pdf");
    }
    
}

}

Hello,
please try the latest version of the export tool,
s3.amazonaws.com/uploads.hipcha … 130312.zip
does the issue occurs in this version? If so, please provide the xml data that recieved on this line, so we could inspect it xml = this.Server.UrlDecode(xml);

Yes. I am able to export the 3000 rows. :laughing:

Is there any possible to export the selected rows, suppose if i want to export 10, 100 or 200 rows?.

I am using checkbox to select the rows for exporting into Excel.

Thanks,
Dhivya

Is there any possible to export the selected rows from DHTML Grid?

Only selected or to highlight selected rows in generated PDF/Excel?

We want to Export only the selected rows to excel. The selection will be done using the checkbox in the grid. We tried the below option but it did not work.

mygrid.setSerializationLevel(false,false,false,false,true);

Hi,
you should try the follow:

grid.toExcel(url,mode,false,false,[]);

The last parameter is and array of rows id. If parameter ignored then all rows are exported, otherwise only rows from this list must be exported.