Lightswitch多对多控制

时间:2015-06-30 03:24:33

标签: many-to-many visual-studio-lightswitch

我有一个多对多的控制复选框列表,用户可以在其中选择项目。我想知道默认情况下,如果在初始化数据工作空间方法屏幕上加载屏幕时可以选择列表。

由于

1 个答案:

答案 0 :(得分: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 });
    
  3. (1)指您当前所在的屏幕

    (2)引用左侧面板(ShippingDetail)中表格的名称

    (3)引用解决方案资源管理器(ShippingDetails)中表的名称