<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" trace="true">
    <a:init-procedure><![CDATA[     
    ]]></a:init-procedure>
    <a:view>
        <a:link id="fnd_sap_field_maps_link" url="${/request/@context_path}/modules/fnd/fnd_sap_field_maps.lview"/>
        <script type="text/javascript"><![CDATA[
            function querySegmentMapCode(){
                $('fnd_sap_segment_maps_result_ds').query();
            }
            function segmentCodeEditor(record,name){
                if (record.isNew){
                    return 'fnd_sap_segment_maps_grid_textField';
                }else{
                    return '';
                }
            }
            function detailRenderFunction(value, record, name){
                if(!record.isNew){
                    var header_id = record.get('header_id');
                    var url = /*fnd_sap_field_maps.screen*/$('fnd_sap_field_maps_link').getUrl()+'?header_id=' + record.get('header_id');
                    //return "<a href=javascript:newWindow(url)>明细</a>";
                    return '<a href="javascript:openWindow(\''+url+'\')">'+'${l:BGT_CONTROL_STRATEGY_GROUPS.DETAIL}'+'</a>';
                }else{
                	return '';
                }
            }
            function newWindow(url){
                new Leaf.Window({id:'fnd_sap_field_maps_window', url:url, title:'BGT_CONTROL_STRATEGY_GROUPS.DETAIL', height:600,width:800});
            }
            function openWindow(url){
                window.open(url);
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="fnd_sap_segment_maps_query_ds" model="fnd.fnd_sap_segment_maps"/>
            <a:dataSet id="fnd_sap_segment_maps_result_ds" autoCreate="true" autoQuery="true" fetchAll="false" model="fnd.fnd_sap_segment_maps" pageSize="15" queryDataSet="fnd_sap_segment_maps_query_ds">
                <a:fields>
                    <a:field name="header_id"/>
                    <a:field name="segment_name"/>
                    <a:field name="table_name"/>
                </a:fields>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:form column="2" title="fnd_sap_segment_maps.TEMPLATE_CODE_QUERY" width="500">
                <a:textField name="segment_name" bindTarget="fnd_sap_segment_maps_query_ds">
                    <a:events>
                        <a:event name="enterdown" handler="querySegmentMapCode"/>
                    </a:events>
                </a:textField>
                <a:textField name="table_name" bindTarget="fnd_sap_segment_maps_query_ds" typeCase="upper">
                    <a:events>
                        <a:event name="enterdown" handler="querySegmentMapCode"/>
                    </a:events>
                </a:textField>
            </a:form>
            <a:hBox>
                <a:button click="querySegmentMapCode" text="HAP_QUERY"/>
            </a:hBox>
            <a:grid id="fnd_sap_segment_maps_grid" bindTarget="fnd_sap_segment_maps_result_ds" marginHeight="150" marginWidth="40" navBar="true" width="800">
                <a:toolBar>
                    <a:button type="add"/>
                    <a:button type="clear"/>
                    <a:button type="save"/>
                </a:toolBar>
                <a:columns>
                    <a:column name="segment_name" editor="fnd_sap_segment_maps_grid_textField" editorFunction="segmentCodeEditor" width="200"/>
                    <a:column name="table_name" editor="fnd_sap_segment_maps_grid_textField" editorFunction="segmentCodeEditor" width="200"/>
                    <a:column name="detail" renderer="detailRenderFunction"/>
                </a:columns>
                <a:editors>
                    <a:textField id="fnd_sap_segment_maps_grid_textField"/>
                    <a:checkBox id="fnd_sap_segment_maps_grid_checkbox"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>