Answered by:
lightswitch

Question
-
hi. we can learn how to calculate a culumn data pleaz. in lightswitch
- Moved by Jack Zhai-MSFTMicrosoft contingent staff Monday, August 19, 2013 12:01 PM Move to a more appropriate forum.
Sunday, August 18, 2013 5:50 PM
Answers
-
- Proposed as answer by Huy Nguyen MSFTMicrosoft employee Friday, August 23, 2013 11:05 PM
- Marked as answer by Amy PengMicrosoft employee, Moderator Tuesday, August 27, 2013 5:34 AM
Monday, August 19, 2013 12:50 PM -
If this is for the LightSwitch HTML Client see:
Computed Properties With the LightSwitch HTML Client
Because as of now computed properties created on the data layer will not show up in the HTML Client.
Also see:
for something that comes close:
// Calculated field to count Available OrderDetails myapp.Order.prototype.getAvailable = function () { return this.OrderDetails.sum(function (item) { return item.ItemAvailable == true; }); }; // Calculated field to count UnAvailable OrderDetails myapp.Order.prototype.getUnAvailable = function () { return this.OrderDetails.sum(function (item) { return item.ItemAvailable == false; }); };
myapp.AddEditOrder.AvailableItems_postRender = function (element, contentItem) { // Get the Order on the screen var order = contentItem.screen.Order; // Show the current count element.innerText = order.getAvailable(); // Method that will be called on update of count function updateValue() { element.innerText = order.getAvailable(); } // Add event listener order.OrderDetails.addEventListener( "collectionchange", updateValue); // Trigger load of OrderDetails order.getOrderDetails(); // Clean up event listener contentItem.handleViewDispose(function () { parent.Children.removeEventListener( "collectionchange", updateValue); }); }; myapp.AddEditOrder.UnAvailableItems_postRender = function (element, contentItem) { // Get the Order on the screen var order = contentItem.screen.Order; // Show the current count element.innerText = order.getUnAvailable(); // Method that will be called on update of count function updateValue() { element.innerText = order.getUnAvailable(); } // Add event listener order.OrderDetails.addEventListener( "collectionchange", updateValue); // Trigger load of OrderDetails order.getOrderDetails(); // Clean up event listener contentItem.handleViewDispose(function () { parent.Children.removeEventListener( "collectionchange", updateValue); }); };
Unleash the Power - Get the LightSwitch HTML Client book
http://LightSwitchHelpWebsite.com
- Edited by ADefwebserver Monday, August 19, 2013 1:12 PM spelling
- Proposed as answer by Huy Nguyen MSFTMicrosoft employee Friday, August 23, 2013 11:05 PM
- Marked as answer by Amy PengMicrosoft employee, Moderator Tuesday, August 27, 2013 5:34 AM
Monday, August 19, 2013 1:12 PM
All replies
-
Hi,
I am moving your thread into the Visual Studio LightSwitch - General Questions Forum for dedicated support. Thanks for your understanding.
Best Regards,
Jack Zhai[MSFT]
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.Monday, August 19, 2013 12:00 PM -
- Proposed as answer by Huy Nguyen MSFTMicrosoft employee Friday, August 23, 2013 11:05 PM
- Marked as answer by Amy PengMicrosoft employee, Moderator Tuesday, August 27, 2013 5:34 AM
Monday, August 19, 2013 12:50 PM -
If this is for the LightSwitch HTML Client see:
Computed Properties With the LightSwitch HTML Client
Because as of now computed properties created on the data layer will not show up in the HTML Client.
Also see:
for something that comes close:
// Calculated field to count Available OrderDetails myapp.Order.prototype.getAvailable = function () { return this.OrderDetails.sum(function (item) { return item.ItemAvailable == true; }); }; // Calculated field to count UnAvailable OrderDetails myapp.Order.prototype.getUnAvailable = function () { return this.OrderDetails.sum(function (item) { return item.ItemAvailable == false; }); };
myapp.AddEditOrder.AvailableItems_postRender = function (element, contentItem) { // Get the Order on the screen var order = contentItem.screen.Order; // Show the current count element.innerText = order.getAvailable(); // Method that will be called on update of count function updateValue() { element.innerText = order.getAvailable(); } // Add event listener order.OrderDetails.addEventListener( "collectionchange", updateValue); // Trigger load of OrderDetails order.getOrderDetails(); // Clean up event listener contentItem.handleViewDispose(function () { parent.Children.removeEventListener( "collectionchange", updateValue); }); }; myapp.AddEditOrder.UnAvailableItems_postRender = function (element, contentItem) { // Get the Order on the screen var order = contentItem.screen.Order; // Show the current count element.innerText = order.getUnAvailable(); // Method that will be called on update of count function updateValue() { element.innerText = order.getUnAvailable(); } // Add event listener order.OrderDetails.addEventListener( "collectionchange", updateValue); // Trigger load of OrderDetails order.getOrderDetails(); // Clean up event listener contentItem.handleViewDispose(function () { parent.Children.removeEventListener( "collectionchange", updateValue); }); };
Unleash the Power - Get the LightSwitch HTML Client book
http://LightSwitchHelpWebsite.com
- Edited by ADefwebserver Monday, August 19, 2013 1:12 PM spelling
- Proposed as answer by Huy Nguyen MSFTMicrosoft employee Friday, August 23, 2013 11:05 PM
- Marked as answer by Amy PengMicrosoft employee, Moderator Tuesday, August 27, 2013 5:34 AM
Monday, August 19, 2013 1:12 PM