lightswitch html客户端设置了详细信息选择器的默认值

时间:2015-09-10 01:45:45

标签: html client visual-studio-lightswitch

我正在尝试为lightswitch html客户端中的详细信息选择器设置默认值。我试过了:

var picker = screen.findContentItem(" SelectedItemType");     picker.value =" MONITOR&#34 ;;

我正在尝试在创建的屏幕方法中设置它。

感谢

1 个答案:

答案 0 :(得分:0)

看看这个帖子我自己问,这应该可以解决你的问题,如果你有任何问题可以随意问:)

Lightswitch HTML Client - set modal picker value when screen created

但是你应该使用什么代码:

  1. 将其粘贴到JS文档的第2行:

    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.ProjectHandlerData[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. 在屏幕上创建的事件
  3. ,输入此代码(修改屏幕值和表名以匹配您的:

    myapp.AddEditHolidayRequest.created = function(screen){

    var defaultValue = "Monitor";
    var filter = "(ProductName eq " + msls._toODataString(defaultValue, ":String") + ")";
    defaultLookup(screen.Order, "Part", "Parts", { filter: filter });
    

    }

  4. ProductName:这是在数据库表中调用的列名,其名称为&#34; Monitor&#34;存储在。

    screen.Order是你的任何屏幕

    1的差异。&#34; Part&#34;和2.&#34;部件&#34;

    1. 如果您要从解决方案资源管理器中打开该表,则在数据源文件夹下,此处顶部显示的名称将在数字1中

    2. 将是您的表的名称,如右侧解决方案资源管理器中的数据源所示