如何在客户端启用devexpress MVC上传控件

时间:2015-10-06 08:03:01

标签: model-view-controller devexpress

我尝试启用MVC上传控件时遇到问题。上载控件最初被禁用。我希望当用户在CheckBoxList中选择一个选项时启用上传控件。 UploadControl不允许在客户端更改其启用状态,但如何执行此操作。你能帮助我,并举例说明如何用回发或其他方式做到这一点。

1 个答案:

答案 0 :(得分:0)

将UploadControl放在CallbackPanel

in Connector.php line 55
at PDO->__construct('sqlite:/srv/http/laravel/storage/database.sqlite', null, null, array('0', '2', '0', false, false)) in Connector.php line 55
at Connector->createConnection('sqlite:/srv/http/laravel/storage/database.sqlite', array('driver' => 'sqlite', 'database' => '/srv/http/laravel/storage/database.sqlite', 'prefix' => '', 'name' => 'sqlite'), array('0', '2', '0', false, false)) in SQLiteConnector.php line 37
at SQLiteConnector->connect(array('driver' => 'sqlite', 'database' => '/srv/http/laravel/storage/database.sqlite', 'prefix' => '', 'name' => 'sqlite')) in ConnectionFactory.php line 60
at ConnectionFactory->createSingleConnection(array('driver' => 'sqlite', 'database' => '/srv/http/laravel/storage/database.sqlite', 'prefix' => '', 'name' => 'sqlite')) in ConnectionFactory.php line 49
at ConnectionFactory->make(array('driver' => 'sqlite', 'database' => '/srv/http/laravel/storage/database.sqlite', 'prefix' => ''), 'sqlite') in DatabaseManager.php line 175
at DatabaseManager->makeConnection('sqlite') in DatabaseManager.php line 67
at DatabaseManager->connection(null) in Model.php line 3245
at Model::resolveConnection(null) in Model.php line 3211
at Model->getConnection() in Model.php line 1914
at Model->newBaseQueryBuilder() in Model.php line 1857
at Model->newQueryWithoutScopes() in Model.php line 1831
at Model->newQuery() in Model.php line 667
at Model::all() in ArticlesController.php line 14
at ArticlesController->index()
at call_user_func_array(array(object(ArticlesController), 'index'), array()) in Controller.php line 256
at Controller->callAction('index', array()) in ControllerDispatcher.php line 164
at ControllerDispatcher->call(object(ArticlesController), object(Route), 'index') in ControllerDispatcher.php line 112
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 114
at ControllerDispatcher->callWithinStack(object(ArticlesController), object(Route), object(Request), 'index') in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\ArticlesController', 'index') in Route.php line 201
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
at Route->run(object(Request)) in Router.php line 704
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 706
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 671
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42`enter code here`
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54
at require_once('/srv/http/laravel/public/index.php') in server.php line 21

我们将存储一个变量,指示是否在ViewData中启用了UploadControl。所以,我在CallbackPanel局部视图上得到它的值。在我们看来,我们将以下列方式呈现CallbackPanel:

@Html.DevExpress().CallbackPanel(settings =>
{
    settings.Name = "CallbackPanel";
    settings.CallbackRouteValues = new { Controller = "Home", Action = "CallbackPanelPartial" };
    // other settings
    settings.SetContent(() =>
    {
        using (Html.BeginForm("UploadControlUpload", "Home", FormMethod.Post))
        {
            Html.DevExpress().UploadControl(s =>
        {
            s.Name = "UploadControl";
            s.CallbackRouteValues = new { Controller = "Home", Action = "UploadControlUpload" };
            // other settings
            s.Enabled = (bool)ViewData["UPEnabled"];
        }).Render();
        }
    });
}).GetHtml()

我们处理CallbackPanel回调的控制器方法是:

@Html.Action("CallbackPanelPartial", new { CPEnabled = false })

检查CheckBox时,向CallbackPanel发送回调以启用UploadControl。为此,请处理the CheckBox CheckedChanged client side event

public ActionResult CallbackPanelPartial(bool CPEnabled) {
    ViewData["UPEnabled"] = CPEnabled;
    return PartialView("_CallbackPanelPartial");
}