Sunday, March 11, 2012

Datatable in ATLAS

Hi,

pratibk:


var stockLabel = new Sys.UI.Label('quote')


this statement is suspect, because you should pass a dom element to the constructor and not an id. Try with:

var stockLabel = new Sys.UI.Label($('quote'));

pratibk:


ALso in this case , i could have also set the value of the label as a html element instead of making it an ATLAS control. What is the specific advantage in making it an atlas control and binding.


the same advantage to use asp.net server controls instead of static html elements: you transform them into dynamic controls. In this case using an Atlas control makes you able to easily add behaviors and bindings (bindings are a powerful feature).

it still doesnt work -

function

callComplete(result)

{

alert(result);

var dataTable = result;var data = dataTable.getItem(0).getProperty("symbol");var stockLabel =new Sys.UI.Label($('quote'));var binding1 =new Sys.Binding();

binding1.set_dataContext = data;

binding1.set_path =

'symbol';

binding1.set_property =

'value';

stockLabel.get_bindings().add(binding1);

stockLabel.initialize();

}

'symbol' is my column name in the datatable returned from the webservice and quote is the html element -

<label id='quote'>


Also garbin, a clarification -

can i make any atlas client control available at the server by putting the runat=server attribute ? and would that mean that for any client control i would be able to access the entire server object model as well ?

Also, where can i get the entire object model info for all atlas client controls and server controls. ?

Thanks ,

Pratibha


Hi,

pratibk:


it still doesnt work -


ok but is it raising any errors?
Hi,

pratibk:


can i make any atlas client control available at the server by putting the runat=server attribute


no, this can't be done. What you can do is making a server control render some Atlas markup which will be parsed to instantiate client controls.

pratibk:


where can i get the entire object model info for all atlas client controls and server controls. ?


please check theAtlas Documentation. It provides also aclass browser to see the code for the client part of the framework.

It continues to give me the same js error - this.element.style.displaymode is null.


Hi,

pratibk:


this.element.style.displaymode is null.

I don't know where the displaymode field is coming from. Are you trying to access the display property?

this.element.style.display

I have not used styl.display anywhere in the page..below is my entire aspx page
 
<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" EnableEventValidation="false" Inherits="_Default" %><%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <link rel="stylesheet" type="text/css" href="CSS/Examples.css" /> <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" > <Services > <atlas:ServiceReference Path="GetNewsHeadlines.asmx"/> <atlas:ServiceReference Path="GetStockPrices.asmx"/> <atlas:ServiceReference Path="GetSoccerScore.asmx"/> </Services> </atlas:ScriptManager> <script type="text/javascript"> function OnApplicationLoad() { GetNewsHeadlines.getNews( //paramsGetCompanyDetails OnComplete, //Complete event OnTimeout //Timeout event ); return false; } function OnComplete(result) { $('output').control.set_data(result); } function OnTimeout(result) { alert("Timed out"); } function GetStockQuote(txtCompName) { GetStockPrices.getStockQuotes(txtCompName.value,callComplete); } function callComplete(result) { alert(result); var dataTable = result; var data = dataTable.getItem(0).getProperty("symbol"); alert(data); var stockLabel = new Sys.UI.Label('stockQuote') var binding1 = new Sys.Binding(); binding1.set_dataContext = data; binding1.set_path = 'symbol'; binding1.set_property = 'text'; stockLabel.get_bindings().add(binding1); stockLabel.initialize(); } </script></head><body> <form id="form1" runat="server"> <table align="center" border="1" width="80%" height="100%"> <tr> <td colspan="2"> <img alt="" src="images/Header.gif" /></td> <atlas:UpdateProgress ID="uprProgress" runat="server"> <ProgressTemplate> Data Being retreived.... </ProgressTemplate> </atlas:UpdateProgress> </tr> <tr><!--Column shows the client side databinding feature--> <td width="50%"> </td><!--This column demonstrates the autocompletion behavior>--> <td width="50%" valign=top> <table > <tr valign=top><td class="headerItem" valign="top">Stock Quote</td></tr> <tr> <td> <input class="inputStyle" type="text" id="txtCompName"/> <input type="button" id="txtButton" class="btnStyl" value ="Get Stock Quote" onclick="GetStockQuote(txtCompName);"/> </td> </tr> <tr> <td><label id="stockQuote"/></td> </tr> </table> </td> </tr><!--Row to demonstrate partial rendering of the page--> <tr> <td width="50%" valign=top> </td><!--Get Cricket Score--> <td valign="top"> </td> </tr> <tr> <td> <atlas:TimerControl Enabled="true" ID="timer1" Interval="5000" runat="server" OnTick="timer1_Tick"></atlas:TimerControl> </td> </tr> </table> </form> <script type="text/xml-script"> <page xmlns:script="http://schemas.microsoft.com/xml-script/2005"> <references> </references> <components> <textBox id="txtCompName"> <behaviors> <autoComplete serviceURL ="GetSymbols.asmx" serviceMethod="GetSymbolNames" minimumPrefixLength="1" completionSetCount="8" completionInterval="200" /> </behaviors> </textBox> </components> </page> </script></body></html>

i found one mistake which i fixed , the $ sign was missing while creating an atlas control out of the label.

But now i get another error that says -

"No data context available for binding with ID = "" and datapath "" on object of type sys.ui.label"


Hi,

pratibk:


binding1.set_dataContext = data;
binding1.set_path = 'symbol';
binding1.set_property = 'text';


these statements are wrong. A setter (set_*) is a method and thus you have to pass the value as an argument. For example:

binding1.set_property('text');

Thanks for the correction Garbin, strange i overlooked this mistake.

One last hurdle to get this working, i am unable to get the right value to set for the set_path setter. I have given the column name from the datatable but that gives me an error saying 'object doesnt support this property'.

Thanks,

Pratibha


Hi,

which syntax are you using to get the value from the datatable?

Checkthis post from my blog, for a DataTable reference.

No comments:

Post a Comment