Made slight progress. Reflected the code and found the DataTableConverter in the Preview assembly that comes with the CTP Beta. Added the following to my web.config:
<jsonSerializationmaxJsonLength="5000000">
<converters>
<addname="DataTableConverter"type="Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter"/>
</converters>
</jsonSerialization>
But, the DataTable that gets returned is missing methods it used to have, such as get_length().
Argh. This just sucks.
OK. I think after digging around I've got it. At least it appears as such.
First thing, after adding a reference to the Preview CTP Beta assembly, and adding the converter for the data table to your web.config, then make sure you add the PreviewScript.js to your project, and add a reference to it in your pages ScriptReference tag, in the ScriptManager. Then, once you have that, then you can instantiate a new DataTable, like so:
<snip>
onGetAllTabsComplete: function(tbl) {
if (tbl != null) {
eval('var tblrows = ' + tbl.dataArray.slice(0, tbl.dataArray.length-1) + ';'); <-- NOTE THIS LINE. I THINK THERE'S A BUG, SINCE THE dataArray has a trailing ')'.
tbl = new Sys.Preview.Data.DataTable(tbl.columns, tblrows);
for (var i = 0; i < tbl.get_length(); i++) {
var row = tbl.getItem(i);
_editor.createTabNode(row.getProperty("ID"), row.getProperty("Title"), row.getProperty("MenuItemID"));
}
}
</snip>
Atlas team, what in the hell is up?! This is, frankly, one of the most bass-ackwards releases I've ever seen from you guys. How, after so many friggin CTP's, do you just bust out and drop this crap on us.
Pissed in San Antonio,
William
Thanks William. This is good info.
Wally
wrote in message news:1443001@.forums.asp.net...
> OK. I think after digging around I've got it. At least it appears as such.
>
> First thing, after adding a reference to the Preview CTP Beta assembly,
> and adding the converter for the data table to your web.config, then make
> sure you add the PreviewScript.js to your project, and add a reference to
> it in your pages ScriptReference tag, in the ScriptManager. Then, once you
> have that, then you can instantiate a new DataTable, like so:
>
>
>
> onGetAllTabsComplete: function(tbl) {
> if (tbl != null) {
> eval('var tblrows = ' + tbl.dataArray.slice(0,
> tbl.dataArray.length-1) + ';');
> THERE'S A BUG, SINCE THE dataArray has a trailing ')'.
> tbl = new Sys.Preview.Data.DataTable(tbl.columns,
> tblrows);
> for (var i = 0; i
> var row = tbl.getItem(i);
> _editor.createTabNode(row.getProperty("ID"),
> row.getProperty("Title"), row.getProperty("MenuItemID"));
> }
> }
>
>
>
>
> Atlas team, what in the hell is up?! This is, frankly, one of the most
> bass-ackwards releases I've ever seen from you guys. How, after so many
> friggin CTP's, do you just bust out and drop this crap on us.
>
> Pissed in San Antonio,
>
> William
>
Listen to the ASP.NET Podcast @.http://www.aspnetpodcast.com/
I use Preview CTP Norvember Beta assembly, and make client source as follow.
tbl = new Sys.Preview.Data.DataTable(tbl.columns, tblrows);
No matter how tbl.columns and tblrows is not null, I get the result zero of tbl.get_length();
Why?
Maybe bug of Sys.Preview.Data.DataTable creator.
In Microsoft.Web.Resources.ScriptLibrary.PreviewScript.js, when the Sys.Preview.Data.DataTable instance create,
to compare Array type and arguments tbl.columns and tblrows is mistake.
Hence, I'll modify the client source as follow.
function Button1_onclick() {
var results = GauceWebService.Select(OnSuccess);
return false;
}
function OnSuccess(result)
{
var tblrows = new Array();
var tblcols = new Array();
var strRowsData = "";
var strColssData = "";
if (result != null)
{
//debugger;
result.dataArray = result.dataArray.slice(0, result.dataArray.length-1);
strRowsData = result.dataArray.substring(1);
strRowsData = strRowsData.substring(0, strRowsData.length-1);
tblrows = strRowsData.split("},{");
for(var j=0; j< tblrows.length; j++)
{
if(j==0)
{
tblrows[j] = tblrows[j].toString().substring(1);
}
else if(j==tblrows.length-1)
{
tblrows[j] = tblrows[j].toString().substring(0, tblrows[j].toString().length-1);
}
}
strColssData = result.columns.substring(1);
strColssData = strColssData.substring(0, strColssData.length-1);
//alert("strColssData = " + strColssData);
tblcols = strColssData.split("),");
for(var j=0; j< tblcols.length; j++)
{
if(j< tblcols.length-1)
{
tblcols[j] = tblcols[j].toString() + ")";
}
}
//result = new Sys.Preview.Data.DataTable(result.columns, tblrows); // Maybe result.columns and tblrows type are string...
result = new Sys.Preview.Data.DataTable(tblcols, tblrows);
//alert("result.get_length() = " + result.get_length());
for (var i = 0; i < result.get_length(); i++) {
var row = result.getItem(i);
alert("Row[" + (i+1) + "] \r\n" + "Name=" + getProperty(row, "Name") + "\r\n" + "LastName=" + getProperty(row, "LastName") + "\r\n" + "Email=" + getProperty(row, "Email"));
//alert("Name=" + row.getProperty("Name") + "," + "LastName=" + row.getProperty("LastName") + "," + "Email=" + row.getProperty("Email"));
}
}
}
function getProperty(rowObj, name)
{
var rowstring = rowObj._row;
var strColValue = "";
var strKeyName = "\"" + name + "\":";
var nLastIndex = rowstring.lastIndexOf(strKeyName);
if(nLastIndex == -1)
{
return "";
}
else
{
var strTmpValue = rowstring.substring(nLastIndex + strKeyName.length-1);
if(strTmpValue.indexOf(",") == -1)
strColValue = strTmpValue.substring(2, strTmpValue.length-1);
else
strColValue = strTmpValue.substring(2, strTmpValue.indexOf(",")-1);
}
return strColValue;
}
No comments:
Post a Comment