如何在不更改源的情况下将数据窗口的数据源从过程更改为查询?

时间:2018-01-25 08:00:03

标签: datasource procedure powerbuilder datawindow

PowerBuilder 12.5

我不想编辑datawindow对象源代码,我想更改数据窗口的数据源,我使用存储过程。我想使用不同的存储过程或查询。如何在不编辑datawindow源的情况下做到这一点?

2 个答案:

答案 0 :(得分:1)

如果我在你的情况下我将使用另一个存储过程调用创建另一个数据窗口,然后我将使用if-then-else更改它们之间的数据对象。 如果你需要有完全相同的数据对象,那么我会尝试使用检索args并发送一个区分两个不同选项的值作为检索,然后你可以在数据源中使用IF-THEN-ELSE。

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<style>
    .stripe-button-el
    {
        visibility: hidden !important;
    }
    .giveButton {
        background: #3D94F6;
        background-image: -webkit-linear-gradient(top, #e9e9e9, #f8f8f8);
        background-image: -moz-linear-gradient(top, #e9e9e9, #f8f8f8);
        background-image: -ms-linear-gradient(top, #e9e9e9, #f8f8f8);
        background-image: -o-linear-gradient(top, #e9e9e9, #f8f8f8);
        background-image: linear-gradient(to bottom, #e9e9e9, #f8f8f8);
        -webkit-border-radius: 20px;
        -moz-border-radius: 20px;
        border-radius: 20px;
        color: #747474;
        font-family: Open Sans;
        font-size: 46px;
        font-weight: 100;
        padding: 1px;
        box-shadow: 1px 1px 7px 0px #000000;
        -webkit-box-shadow: 1px 1px 2px 0px #000000;
        -moz-box-shadow: 1px 1px 2px 0px #000000;
        text-shadow: 3px 0px 5px #d4d4d4;
        border: solid #bababa 1px;
        text-decoration: none;
        display: inline-block;
        cursor: pointer;
        text-align: center;
        font-family: 'Anton', sans-serif;
    }
    .giveButton span{
        top: -15px;
        position: relative;
        left: -6px;
        font-size: 33px;}

    .giveButton:hover {
        background: #1E62D0;
        background-image: -webkit-linear-gradient(top, #0c8955, #71f68f);
        background-image: -moz-linear-gradient(top, #0c8955, #71f68f);
        background-image: -ms-linear-gradient(top, #0c8955, #71f68f);
        background-image: -o-linear-gradient(top, #0c8955, #71f68f);
        background-image: linear-gradient(to bottom, #0c8955, #71f68f);
        text-decoration: none;
        color: white;
    }
    .SelectedButton
    {
        background-image: -webkit-linear-gradient(top, #0c8955, #71f68f);
        background-image: -moz-linear-gradient(top, #0c8955, #71f68f);
        background-image: -ms-linear-gradient(top, #0c8955, #71f68f);
        background-image: -o-linear-gradient(top, #0c8955, #71f68f);
        background-image: linear-gradient(to bottom, #0c8955, #71f68f);
        text-shadow: 3px 0px 5px #7c7c7c;
        color: white; 
    }
</style>

<div class="container">

    <div class="row">
        <div class="col-4 text-center"><div class="giveButton w-100"><span>$</span>25</div></div>
        <div class="col-4 text-center"><div class="giveButton w-100"><span>$</span>50</div></div>  
        <div class="col-4 text-center"><div class="giveButton w-100"><span>$</span>100</div></div>
    </div>

    <div class="row">
        <div class="col-4 text-center"><div class="giveButton w-100"><span>$</span>250</div></div>  
        <div class="col-4 text-center"><div class="giveButton w-100"><span>$</span>500</div></div>  
        <div class="col-4 text-center"><div class="giveButton w-100"><span>$</span>1,000</div></div>
    </div>

    <div class="row">
        <div class="col-12 text-center">
        <div class="giveButton w-100"><span>$</span>5,000</div>
        </div>  
        <div class="col-12 text-center">
        <div class="giveButton w-100"><span>$</span>10,000</div>
        </div>  
    </div>

</div>

希望它有所帮助!

答案 1 :(得分:1)

我还会创建一个新的数据窗口,其中包含您的过程作为数据源。然后使用它,使用sharedata()函数。 更具体地说,如果你有一个datawidnows控件dw_1持有你的'旧'数据窗口,创建一个新的(可能是隐藏的)控件dw_new并在其中使用新的数据对象。或者,您可以使用数据存储区。 然后代码:

dw_1.reset // To make sure everything has been flushed
dw_new.retrieve()
dw_new.sharedata(dw_1)

这种工作的绝对条件是具有完全相同的缓冲区,即具有相同定义的相同字段。