开发者

Accessing sharepoint from caml

How can I add javascript to my CAML code?

For example, I want to calculate some rates/dates according to local field on Sharepoint list.

I want to set value of field according to the javascript result.

Any Idea ?

Poli开发者_开发技巧 .


You can add JavaScript to your page, not to CAML. CAML is used to query Sharepoint lists. The results will be rendered as HTML Have a look at the rendered HTML and go from there.


You can't really "add" javascript code to a CAML query because CAML queries run on the server where as javascript runs client side.

Say you have a query like this :

SPQuery query = new SPQuery();

query.Query = "<Where><Eq><FieldRef Name='FieldName' /><Value Type='Text'>TestValue</Value></Eq></Where>";

When you run your query :

SPListItemCollection items = list.GetItems(query);

You will end up with your items. This is where you can modify them and run your logic code (in your backend code).

For example :

foreach(SPListItem item in SPListItemCollection) { int rate = item["SomeField"].ToString() + item["SomeOtherField"].ToString(); //Do whatever you want with the result }

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜