2015-06-30 44 views
0

我有一個多對多的控件複選框列表,用戶可以選擇項目。我想知道默認情況下,當在初始化數據工作區方法屏幕上加載屏幕時,是否可以選擇列表。Lightswitch多對多控制

感謝

回答

0

在關於這個職位,這應該幫助您設置的細節默認值選取器。(HTML客戶端)

Lightswitch HTML Client - set modal picker value when screen created

但作爲鏈接可以打破,繼承人如何做到這一點的總結...

  1. 將下面的代碼添加到屏幕的js文件(更改應用程序數據到您的數據源)

    function defaultLookup (entity, destinationPropertyName, sourceCollectionName, options) { 
    /// <summary> 
    /// Defaults an entity's lookup property 
    /// </summary> 
    /// <param name="entity" type="Object">The entity featuring the lookup property to default</param> 
    /// <param name="destinationPropertyName" type="String">The lookup property against the entity to default</param> 
    /// <param name="sourceCollectionName" type="String">The collection from which to source the lookup value</param> 
    /// <param name="options" type="PlainObject" optional="true"> 
    /// A set of key/value pairs used to select additional configuration options. All options are optional. 
    /// <br/>- String filter: If supplied, defines the match condition for the required default, otherwise the lookup defaults to the first entry in the source collection 
    /// </param> 
    options = options || {}; // Force options to be an object 
    var source = myapp.activeDataWorkspace.ApplicationData[sourceCollectionName]; // DataServiceQuery 
    var query = {}; //DataServiceQuery 
    if (options.filter) { 
        query = source.filter(options.filter); 
    } else { 
        query = source.top(1); 
    } 
    query.execute().then(function (result) { 
        entity[destinationPropertyName] = result.results[0]; 
    }); 
    

    };

  2. 設置於外鍵爲主(這是屏幕創建的代碼下)的值:

    var defaultValue = "Goods in"; 
    //screen.ShippingDetails.ShippingName; 
    var filter = "(ShippingName eq " + msls._toODataString(defaultValue, ":String") + ")"; 
    defaultLookup((1)screen.Order, "(2)ShippingDetail", "(3)ShippingDetails", { filter: filter }); 
    

(1)指的是你目前

屏幕(2 )引用左側面板中的表名稱(ShippingDetail)

(3)引用解決方案資源管理器(ShippingDetails)中的表名稱

+0

對不起,我的意思是Silverlight客戶端 – jason