-
20 Feb 2009 1:40 PM #151
Hii stevenhzj,
Firstly welcome to ExtJS world.
You said "store.data.length = 0", you should use getCount() method of store.
since "data" is config params.
-
20 Feb 2009 6:10 PM #152
hi emredagli
ye i use getCount() is also 0.
the store is through asynchronous get. so in store.load(), use getCount() is 0,
can i use callback to getCount() ? how to do? THK!
-
21 Feb 2009 4:37 AM #153
Mr. stevenhzj,
It is better to send your code.
It is hard to say what you sholud do without knowing what you are trying to do.
-
21 Feb 2009 6:52 PM #154
hi emredagli
this the button code:
another WebService Code:Code:buttons: [{ id: 'grid-excel-button', text: 'Export to Excel...', handler: function(){ var max = store.getCount(); var downstore = new Ext.data.Store({ url: 'http://localhost/ExtTestWebService/Service_Test.asmx/GetArticles', // Web Service Site reader: new Ext.data.XmlReader( { totalRecords: 'totalRecords', record: 'record', id: 'id' }, [ {name: 'id'}, {name: 'name'}, {name: 'code'}, {name: 'joindate'} ] ), remoteSort: true // }); downstore.on('beforeload', function(downstore) { downstore.baseParams={consql:v_consql}; } ); downstore.load({params:{start:0,limit:max}}); // vExportContent = grid.getExcelXml(store.data,false); exportExcell(); } }],
Code:[WebMethod] public DataSet GetArticles(string consql, int start, int limit, string sort, string dir) { DataSet ds = new DataSet("Operator"); string strSql = string.Format( "select top {0} * from sys$vw_operator where 1=1 " + consql + " and Id not in (select top {1} Id from sys$vw_operator order by {2} {3}) order by {2} {3}", limit, start, sort, dir); SqlDataAdapter da = new SqlDataAdapter(strSql, _strConn); DataTable dtRecord = new DataTable("record"); lock (da) { da.Fill(dtRecord); } ds.Tables.Add(dtRecord); DataTable dtResult = new DataTable("results"); dtResult.Columns.Add("totalRecords"); DataRow dr = dtResult.NewRow(); using (SqlConnection conn = new SqlConnection(_strConn)) using (SqlCommand cmd = new SqlCommand("select count(*) from sys$vw_operator where 1=1" + consql, conn)) { try { conn.Open(); dr["totalRecords"] = (int)cmd.ExecuteScalar(); } catch { // do nothing } } dtResult.Rows.Add(dr); ds.Tables.Add(dtResult); return ds; }Last edited by mystix; 21 Feb 2009 at 8:14 PM. Reason: post code in [code][/code] tags. see http://extjs.com/forum/misc.php?do=bbcode#code
-
22 Feb 2009 5:48 AM #155
and i want know how use ext and ajaxpro2, i trying to use ,but then conflict.
in Ajaxpro, js code is easy call function c# mothod, i to bo used to.
but i can use in ext, anybody can help me , hope Demo Sample, Ths.
-
22 Feb 2009 10:18 AM #156
This Code may be helpful to generate excel file on server side.
Code:public void generateExcelFile(List<? extends EkaListingDO> listingResults, HttpServletResponse response, HttpServletRequest request, String gridName) throws SystemException { IUserContext userContext = this.getUserContext(request); try { String fileName = gridName + "-" + EkaDateUtil.getTimeStamp(new Date()); String dependentObj = (String) request.getParameter("dependentObj"); JSONObject jsonDependentObj = null; if (EkaStringUtil.isNotEmpty(dependentObj)) { jsonDependentObj = JSONObject.fromObject(dependentObj); } String columnModelState = (String) request .getParameter("columnModelState"); columnModelState = columnModelState.replaceAll( "EKA_INTERNAL_ID_AMP", "&"); columnModelState = columnModelState.replaceAll( "EKA_INTERNAL_ID_HASH", "#"); OutputStream out = null; response.setContentType("application/vnd.ms-excel"); response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".xls"); WritableWorkbook w = Workbook.createWorkbook(response .getOutputStream()); WritableSheet s = w.createSheet(gridName, 0); JSONArray array = JSONArray.fromObject(columnModelState); List<String> listProperties = new ArrayList<String>(); for (int i = 0; i < array.size(); i++) { JSONObject object = (JSONObject) array.get(i); listProperties.add(object.getString("dataIndex")); s.addCell(new Label(i, 0, object.getString("header"))); } String value = null; if (!listProperties.isEmpty()) { for (int i = 0; i < listingResults.size(); i++) { EkaListingDO ekaListingDO = (EkaListingDO) listingResults .get(i); for (int j = 0; j < listProperties.size(); j++) { value = (String) EkaBeanUtil.getBeanProperties( ekaListingDO, listProperties.get(j)); if (EkaStringUtil.isNullOrEmpty(value)) { value = ""; } if (jsonDependentObj != null && jsonDependentObj.containsKey(listProperties .get(j))) { JSONArray array2 = (JSONArray) jsonDependentObj .get(listProperties.get(j)); for (int k = 0; k < array2.size(); k++) { JSONObject innObj = array2.getJSONObject(k); String property = innObj.getString("dependsOn"); String separator = innObj .getString("separator"); String dependentValue = (String) EkaBeanUtil .getBeanProperties(ekaListingDO, property); if (EkaStringUtil.isNullOrEmpty(dependentValue)) { dependentValue = ""; } if (EkaStringUtil.isNotEmpty(value)) { value = value + separator + dependentValue; } } } if (EkaStringUtil.isDoubleContent(value) || EkaStringUtil.isOnlyNumericContent(value)) { s.addCell(new Number(j, i + 1, EkaStringUtil .convertStringToDouble(value))); } else { s.addCell(new Label(j, i + 1, value)); } } } } w.write(); w.close(); if (out != null) { out.close(); } } catch (Exception e) { logger.error(userContext, e); } }Last edited by mystix; 22 Feb 2009 at 10:51 AM. Reason: it might be useful if it was readable... post code in [code][/code] tags. see http://extjs.com/forum/misc.php?do=bbcode#code
-
24 Feb 2009 1:29 PM #157
As an update to my previous issue with OpenOffice vs. MS Excel -- having MS Excel installed worked like a charm opening the generated XLS file. Sorry OpenOffice, you lose this round!
Noah
Senior Web Developer
NBA.com
-
16 Mar 2009 12:34 AM #158
bad post
Last edited by hardc0re; 16 Mar 2009 at 1:28 AM. Reason: USE CODE TAGS!!!!!!!!!!!!!!
-
16 Mar 2009 12:43 AM #159
So you didn't' read the message, and try to find the mistake then? You just blurted your bug here.
READ the XML section which the error message kindly tells you about, and you see
Excel seems not to like that.Code:<Worksheet ss:Name=". la 31.12.2008.xls]Contracte valide si in vigoare">
READ the free code which generates that section, and you see:
Do some work.Code:// Generate worksheet header details. var t = '<ss:Worksheet ss:Name="' + this.title + '">' +Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
16 Mar 2009 1:00 AM #160


Reply With Quote